Skip to content

Commit f8bced5

Browse files
authored
Added Support for Rest-API based Deepgram Aura-2 - Version 0.x. (#2014)
1 parent 33ea86e commit f8bced5

File tree

1 file changed

+10
-2
lines changed
  • livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram

1 file changed

+10
-2
lines changed

livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/tts.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def __init__(
4242
sample_rate: int = 24000,
4343
api_key: str | None = None,
4444
base_url: str = BASE_URL,
45+
use_streaming: bool = True,
4546
word_tokenizer: tokenize.WordTokenizer = tokenize.basic.WordTokenizer(
4647
ignore_punctuation=False
4748
),
@@ -55,13 +56,15 @@ def __init__(
5556
encoding (str): Audio encoding to use. Defaults to "linear16".
5657
sample_rate (int): Sample rate of audio. Defaults to 24000.
5758
api_key (str): Deepgram API key. If not provided, will look for DEEPGRAM_API_KEY in environment.
58-
base_url (str): Base URL for Deepgram TTS API. Defaults to "https://api.deepgram.com/v1/speak"
59+
base_url (str): Base URL for Deepgram TTS API. Defaults to "https://api.deepgram.com/v1/speak".
60+
use_streaming (bool): Whether to use WebSocket-based streaming instead of the REST API. Defaults to True.
5961
word_tokenizer (tokenize.WordTokenizer): Tokenizer for processing text. Defaults to basic WordTokenizer.
6062
http_session (aiohttp.ClientSession): Optional aiohttp session to use for requests.
6163
6264
"""
6365
super().__init__(
64-
capabilities=tts.TTSCapabilities(streaming=True),
66+
# checking if the model is from aura-2 family (Aura-2 is currently available for the TTS REST API only.)
67+
capabilities=tts.TTSCapabilities(streaming=use_streaming),
6568
sample_rate=sample_rate,
6669
num_channels=NUM_CHANNELS,
6770
)
@@ -72,6 +75,11 @@ def __init__(
7275
"Deepgram API key required. Set DEEPGRAM_API_KEY or provide api_key."
7376
)
7477

78+
if model.startswith("aura-2") and use_streaming:
79+
logger.warning(
80+
"Deepgram Aura-2 models do not support streaming yet, set use_streaming=False to use Aura-2 models. For more information see: https://developers.deepgram.com/docs/streaming-text-to-speech."
81+
)
82+
7583
self._opts = _TTSOptions(
7684
model=model,
7785
encoding=encoding,

0 commit comments

Comments
 (0)