a basic duplex agent is built
This commit is contained in:
@@ -129,11 +129,21 @@ class SimpleVoiceClient:
|
||||
# JSON event
|
||||
event = json.loads(msg)
|
||||
etype = event.get("event", "?")
|
||||
print(f"<- {etype}")
|
||||
|
||||
if etype == "hangup":
|
||||
if etype == "transcript":
|
||||
# User speech transcription
|
||||
text = event.get("text", "")
|
||||
is_final = event.get("isFinal", False)
|
||||
if is_final:
|
||||
print(f"<- You said: {text}")
|
||||
else:
|
||||
print(f"<- [listening] {text}", end="\r")
|
||||
elif etype == "hangup":
|
||||
print(f"<- {etype}")
|
||||
self.running = False
|
||||
break
|
||||
else:
|
||||
print(f"<- {etype}")
|
||||
|
||||
except asyncio.TimeoutError:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user