Skip to content

Conversation

@lukeocodes
Copy link
Contributor

@lukeocodes lukeocodes commented Dec 2, 2025

This pull request adds a new example script demonstrating how to use the Deepgram API to transcribe audio from a URL with additional query parameters for language detection.

New example for Deepgram API usage:

  • Added examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py to show how to transcribe audio from a URL and specify multiple languages for detection using the detect_language query parameter.
  • Utilizes the dotenv library to load environment variables, ensuring credentials and configuration are securely managed.

Summary by CodeRabbit

  • Documentation
    • Added a new code example showing how to transcribe audio from URLs with enhanced configuration options, including automatic language detection support for multiple languages.

✏️ Tip: You can customize this high-level summary in your review settings.

@lukeocodes lukeocodes self-assigned this Dec 2, 2025
@lukeocodes lukeocodes added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 2, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

A new example script is added to demonstrate transcribing audio from a URL using the Deepgram Client with additional query parameters, specifically setting language detection to English and Spanish.

Changes

Cohort / File(s) Summary
Example script for URL transcription with query parameters
examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py
New example demonstrating how to invoke listen.v1.media.transcribe_url with additional_query_parameters to set language detection options. Includes environment variable loading, client initialization, error handling, and response output.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Verify the example script follows established patterns used in other examples in the same directory
  • Confirm syntax correctness and that imports align with current Deepgram Client API

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: adding a new example script for using additional query parameters in the Deepgram API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lo/add-additional-query-params-example

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new example demonstrating how to use additional query parameters when transcribing a URL with the Deepgram SDK, specifically showing the detect_language parameter with multiple language options.

Key Changes:

  • Adds a new example file showing usage of additional_query_parameters in the transcribe_url method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…uery_parameters.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

@pcgeek86 pcgeek86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py (1)

1-4: Past comment already addressed.

The imports are already correctly placed at the top of the file before the load_dotenv() call, as suggested in the previous review.

🧹 Nitpick comments (1)
examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py (1)

1-23: Consider adding a module docstring.

Adding a brief docstring at the top of the file would help users quickly understand what this example demonstrates.

For example:

+"""
+Example demonstrating how to transcribe audio from a URL with additional query parameters.
+
+This example shows how to use the detect_language parameter to specify multiple
+languages for automatic language detection (English and Spanish).
+"""
+
 from dotenv import load_dotenv
 from deepgram import DeepgramClient
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78ac7b7 and 1ffe1dd.

📒 Files selected for processing (1)
  • examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py (1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: dvonthenen
Repo: deepgram/deepgram-python-sdk PR: 472
File: examples/speech-to-text/websocket/replay/main.py:78-80
Timestamp: 2024-10-18T16:20:17.742Z
Learning: In the `examples` directory of the Deepgram Python SDK, code is intended as illustrative examples and doesn't require production-level error handling.
Learnt from: dvonthenen
Repo: deepgram/deepgram-python-sdk PR: 432
File: deepgram/client.py:65-66
Timestamp: 2024-10-09T02:19:46.086Z
Learning: The `ListenRESTClient` and `AsyncListenRESTClient` imports in `deepgram/client.py` are intentional to support direct invocation, as demonstrated in the `examples/advanced/rest/direct_invocation` example.
Learnt from: dvonthenen
Repo: deepgram/deepgram-python-sdk PR: 432
File: deepgram/client.py:65-66
Timestamp: 2024-07-11T14:25:40.772Z
Learning: The `ListenRESTClient` and `AsyncListenRESTClient` imports in `deepgram/client.py` are intentional to support direct invocation, as demonstrated in the `examples/advanced/rest/direct_invocation` example.
📚 Learning: 2024-10-18T16:20:17.742Z
Learnt from: dvonthenen
Repo: deepgram/deepgram-python-sdk PR: 472
File: examples/speech-to-text/websocket/replay/main.py:78-80
Timestamp: 2024-10-18T16:20:17.742Z
Learning: In the `examples` directory of the Deepgram Python SDK, code is intended as illustrative examples and doesn't require production-level error handling.

Applied to files:

  • examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py
📚 Learning: 2024-10-09T02:19:46.086Z
Learnt from: dvonthenen
Repo: deepgram/deepgram-python-sdk PR: 426
File: deepgram/clients/listen/__init__.py:6-6
Timestamp: 2024-10-09T02:19:46.086Z
Learning: Imports for DeepgramClientOptions and ClientOptionsFromEnv in deepgram/clients/listen/__init__.py should not be flagged as unused in reviews.

Applied to files:

  • examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py
📚 Learning: 2024-07-01T19:12:57.715Z
Learnt from: dvonthenen
Repo: deepgram/deepgram-python-sdk PR: 426
File: deepgram/clients/speak/__init__.py:16-19
Timestamp: 2024-07-01T19:12:57.715Z
Learning: Unused imports in `deepgram/clients/speak/__init__.py` are retained for backward compatibility and should not be flagged for removal in reviews.

Applied to files:

  • examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py
📚 Learning: 2024-07-01T19:17:04.194Z
Learnt from: dvonthenen
Repo: deepgram/deepgram-python-sdk PR: 426
File: deepgram/clients/listen/v1/__init__.py:36-43
Timestamp: 2024-07-01T19:17:04.194Z
Learning: Unused imports in `deepgram/clients/listen/v1/__init__.py` are retained to maintain backward compatibility and should not be flagged for removal in reviews.

Applied to files:

  • examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py
📚 Learning: 2024-07-01T19:13:28.504Z
Learnt from: dvonthenen
Repo: deepgram/deepgram-python-sdk PR: 426
File: deepgram/clients/listen/__init__.py:42-50
Timestamp: 2024-07-01T19:13:28.504Z
Learning: Unused imports in `deepgram/clients/listen/__init__.py` are retained to maintain backward compatibility and should not be flagged for removal in reviews.

Applied to files:

  • examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py
📚 Learning: 2024-10-18T16:19:48.637Z
Learnt from: dvonthenen
Repo: deepgram/deepgram-python-sdk PR: 472
File: examples/speech-to-text/websocket/replay/main.py:23-27
Timestamp: 2024-10-18T16:19:48.637Z
Learning: When initializing `DeepgramClient` without providing an API key, it uses the `DEEPGRAM_API_KEY` environment variable internally.

Applied to files:

  • examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py
🔇 Additional comments (2)
examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py (2)

7-7: LGTM!

The client initialization correctly uses the environment variable approach, which is appropriate for example code.


9-9: LGTM!

The error handling is appropriate for an example script. Based on learnings, examples don't require production-level error handling.

Also applies to: 22-23

Comment on lines +14 to +18
request_options={
"additional_query_parameters": {
"detect_language": ["en", "es"],
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Deepgram API detect_language parameter format documentation

💡 Result:

  • Parameter name and type: detect_language — boolean query parameter (use detect_language=true to enable). [1]

  • URL usage example: https://api.deepgram.com/v1/listen?detect_language=true (can be combined with other params like punctuate=true). [2]

  • Restrict detectable languages: pass detect_language multiple times with language codes, e.g. detect_language=en&detect_language=es to limit detection to English or Spanish. [1]

  • Interaction: if you set both language and detect_language=true, language detection overrides the explicit language parameter. [1]

Sources:
[1] Deepgram Language Detection docs.
[2] Deepgram changelog / blog announcement showing example URL.


🏁 Script executed:

# Search for other uses of detect_language in the codebase
rg "detect_language" -A 2 -B 2

Repository: deepgram/deepgram-python-sdk

Length of output: 24051


🏁 Script executed:

# Search for Deepgram API documentation files or type definitions
fd -e "py" -e "md" | head -20 | xargs rg -l "detect_language|transcribe" | head -10

Repository: deepgram/deepgram-python-sdk

Length of output: 529


🏁 Script executed:

# Check how additional_query_parameters is processed in the SDK
rg "additional_query_parameters" -A 5 -B 5 src/deepgram/listen/v1/media/ | head -50

Repository: deepgram/deepgram-python-sdk

Length of output: 54


🏁 Script executed:

# Look for query parameter handling or serialization logic
fd -e "py" -path "*/src/*" | xargs rg -l "query.*parameter|serialize|format.*query" | head -5

Repository: deepgram/deepgram-python-sdk

Length of output: 439


🏁 Script executed:

# Check the example file to understand context
cat -n examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py

Repository: deepgram/deepgram-python-sdk

Length of output: 769


Remove the list format from detect_language — use individual query parameters instead.

The Deepgram API requires detect_language to be passed as separate query parameters (e.g., detect_language=en&detect_language=es), not as a list. Change "detect_language": ["en", "es"] to pass the language codes as individual parameters through additional_query_parameters.

🤖 Prompt for AI Agents
In examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py
around lines 14 to 18, change the additional_query_parameters so detect_language
is passed as separate query parameters rather than a single list; replace the
current mapping "detect_language": ["en", "es"] with a structure that encodes
duplicate query keys (e.g., a list of ("detect_language", value) pairs or
equivalent supported format) so the final query becomes
detect_language=en&detect_language=es.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants