diff --git a/examples/130-telegram-bot-python/src/bot.py b/examples/130-telegram-bot-python/src/bot.py index bac040c..3aea46f 100644 --- a/examples/130-telegram-bot-python/src/bot.py +++ b/examples/130-telegram-bot-python/src/bot.py @@ -63,17 +63,15 @@ def transcribe_voice(file_path_or_url: str, api_key: str) -> str | None: if not audio_bytes: return None - client = DeepgramClient(api_key) + client = DeepgramClient(api_key=api_key) # SDK v5 Python: transcribe_file() accepts raw bytes. # Deepgram auto-detects the audio format from the file header. # nova-3 is the current flagship model (2025). For phone-call # audio use nova-3-phonecall; for medical dictation use nova-3-medical. response = client.listen.v1.media.transcribe_file( - audio_bytes, + request=audio_bytes, model="nova-3", - # smart_format adds punctuation, capitalisation, and paragraph - # breaks. Adds ~10 ms latency — almost always worth enabling. smart_format=True, tag="deepgram-examples", ) @@ -115,13 +113,9 @@ async def handle_voice(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No # nova-3 is the current flagship model (2025). For phone-call # audio use nova-3-phonecall; for medical dictation use nova-3-medical. response = client.listen.v1.media.transcribe_file( - audio_bytes, + request=audio_bytes, model="nova-3", - # smart_format adds punctuation, capitalisation, and paragraph - # breaks. Adds ~10 ms latency — almost always worth enabling. smart_format=True, - # Telegram voice messages are typically one speaker. Enable - # diarize=True if you expect multi-speaker forwarded recordings. tag="deepgram-examples", ) diff --git a/examples/130-telegram-bot-python/tests/test_example.py b/examples/130-telegram-bot-python/tests/test_example.py index e47c634..e242f5f 100644 --- a/examples/130-telegram-bot-python/tests/test_example.py +++ b/examples/130-telegram-bot-python/tests/test_example.py @@ -8,15 +8,10 @@ # 1 = real test failure (code bug, assertion error, unexpected API response) # 2 = missing credentials (expected in CI until secrets are configured) # -# Note: TELEGRAM_BOT_TOKEN is listed in .env.example because it is needed to -# run the bot, but we only need DEEPGRAM_API_KEY to exercise the core -# transcription logic tested here. -env_example = Path(__file__).parent.parent / ".env.example" -required = [ - line.split("=")[0].strip() - for line in env_example.read_text().splitlines() - if line and not line.startswith("#") and "=" in line and line[0].isupper() -] +# Only DEEPGRAM_API_KEY is needed for the transcription tests below. +# TELEGRAM_BOT_TOKEN is required to *run* the bot but not to test the +# core transcribe_voice() function we exercise here. +required = ["DEEPGRAM_API_KEY"] missing = [k for k in required if not os.environ.get(k)] if missing: print(f"MISSING_CREDENTIALS: {','.join(missing)}", file=sys.stderr)