Skip to content

Commit

Permalink
Add set_output_medium (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdepinet authored Oct 10, 2024
1 parent 01e7e60 commit e7a4220
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ultravox-client/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ultravox-client"
version = "0.0.5"
version = "0.0.6"
packages = [
{ include = "ultravox_client", from = "." },
]
Expand Down
10 changes: 8 additions & 2 deletions ultravox-client/ultravox_client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def is_live(self):


Role = Literal["user", "agent"]
Medium = Literal["text", "voice"]


ClientToolImplementation = Callable[
Expand All @@ -142,7 +143,7 @@ class Transcript:
"""Whether the text is complete or the utterance is ongoing."""
speaker: Role
"""Who emitted the utterance."""
medium: Literal["text", "voice"]
medium: Medium
"""The medium through which the utterance was emitted."""


Expand Down Expand Up @@ -214,6 +215,11 @@ def toggle_speaker_muted(self) -> None:
"""Toggles the mute state of the user's speaker (i.e. output audio from the agent)."""
self.speaker_muted = not self.speaker_muted

async def set_output_medium(self, medium: Medium) -> None:
"""Sets the agent's output medium. If the agent is currently speaking, this will
take effect at the end of the agent's utterance. Also see speaker_muted above."""
await self._send_data({"type": "set_output_medium", "medium": medium})

def register_tool_implementation(
self, name: str, tool_impl: ClientToolImplementation
) -> None:
Expand Down Expand Up @@ -266,7 +272,7 @@ async def leave_call(self):
await self._disconnect()

async def send_text(self, text: str):
"""Sends a message via text. The agent will also respond via text."""
"""Sends a message via text."""
if not self._status.is_live():
raise RuntimeError(
f"Cannot send text while not connected. Current status is {self.status}"
Expand Down

0 comments on commit e7a4220

Please sign in to comment.