Skip to content

Commit

Permalink
sounddevices isn't available in GH actions :/
Browse files Browse the repository at this point in the history
  • Loading branch information
mdepinet committed Sep 5, 2024
1 parent 490ee98 commit 518e4b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 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.1"
version = "0.0.2"
packages = [
{ include = "ultravox_client", from = "." },
]
Expand Down
13 changes: 12 additions & 1 deletion ultravox-client/ultravox_client/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import AsyncGenerator

import numpy as np
import sounddevice


class AudioSource(abc.ABC):
Expand Down Expand Up @@ -58,6 +57,12 @@ def __init__(self, sample_rate: int = 48000, channels: int = 1):
super().__init__(sample_rate, channels)

async def stream(self) -> AsyncGenerator[bytes, None]:
try:
import sounddevice
except ImportError:
raise ImportError(
"The 'sounddevice' module is required for LocalAudioSource."
)
queue: asyncio.Queue[bytes] = asyncio.Queue()
loop = asyncio.get_running_loop()

Expand All @@ -83,6 +88,12 @@ class LocalAudioSink(AudioSink):
"""AudioSink that plays to the default audio device."""

def __init__(self, sample_rate: int = 48000, num_channels: int = 1) -> None:
try:
import sounddevice
except ImportError:
raise ImportError(
"The 'sounddevice' module is required for LocalAudioSink."
)
super().__init__(sample_rate=sample_rate, num_channels=num_channels)
self._queue: deque[bytes] = deque()
self._stream: sounddevice.OutputStream | None = None
Expand Down

0 comments on commit 518e4b7

Please sign in to comment.