Draft
Conversation
|
| ) | ||
| _stt_instance = mistralai.STT( | ||
| client=client, | ||
| model="voxtral-mini-latest", |
Collaborator
There was a problem hiding this comment.
should we make it an env variable?
Comment on lines
38
to
+58
| def create_stt_provider(): | ||
| """Create STT provider based on environment configuration.""" | ||
| if STT_PROVIDER == "deepgram": | ||
| # Note: Not all Deepgram API parameters are supported by the LiveKit plugin | ||
| # detect_language is NOT supported for real-time streaming | ||
| # Use language="multi" instead for automatic multilingual support | ||
| _stt_instance = deepgram.STT( | ||
| model=os.getenv("DEEPGRAM_STT_MODEL", "nova-3"), | ||
| language=os.getenv("DEEPGRAM_STT_LANGUAGE", "multi"), | ||
| ) | ||
| elif STT_PROVIDER == "kyutai": | ||
| _stt_instance = kyutai.STT(base_url=os.getenv("KYUTAI_STT_BASE_URL")) | ||
| elif STT_PROVIDER == "voxtral-realtime": | ||
| client = Mistral( | ||
| api_key=os.getenv("VOXTRAL_REALTIME_STT_API_KEY"), | ||
| server_url=os.getenv("VOXTRAL_REALTIME_STT_BASE_URL"), | ||
| ) | ||
| _stt_instance = mistralai.STT( | ||
| client=client, | ||
| model="voxtral-mini-latest", | ||
| ) |
Collaborator
There was a problem hiding this comment.
we could refactor it to use a factory pattern with a declarative approach based on a decorator.
from typing import Callable, Dict
import os
# Registry of STT provider factories
_STT_PROVIDERS: Dict[str, Callable] = {}
def register_stt_provider(name: str):
"""Decorator to register an STT provider factory."""
def decorator(func: Callable) -> Callable:
_STT_PROVIDERS[name] = func
return func
return decorator
@register_stt_provider("deepgram")
def _create_deepgram_stt():
# Note: Not all Deepgram API parameters are supported by the LiveKit plugin.
# detect_language is NOT supported for real-time streaming.
# Use language="multi" instead for automatic multilingual support.
return deepgram.STT(
model=os.getenv("DEEPGRAM_STT_MODEL", "nova-3"),
language=os.getenv("DEEPGRAM_STT_LANGUAGE", "multi"),
)
@register_stt_provider("kyutai")
def _create_kyutai_stt():
return kyutai.STT(base_url=os.getenv("KYUTAI_STT_BASE_URL"))
@register_stt_provider("voxtral-realtime")
def _create_voxtral_realtime_stt():
client = Mistral(
api_key=os.getenv("VOXTRAL_REALTIME_STT_API_KEY"),
server_url=os.getenv("VOXTRAL_REALTIME_STT_BASE_URL"),
)
return mistralai.STT(
client=client,
model=os.getenv("VOXTRAL_REALTIME_STT_MODEL", "voxtral-mini-latest"),
)
def create_stt_provider():
"""Create STT provider based on environment configuration."""
try:
factory = _STT_PROVIDERS[STT_PROVIDER]
except KeyError:
raise ValueError(
f"Unknown STT provider: {STT_PROVIDER!r}. "
f"Available providers: {sorted(_STT_PROVIDERS)}"
)
return factory()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Purpose
Add support for voxtral realtime stt (live transcription).