-
Notifications
You must be signed in to change notification settings - Fork 114
chore(examples): add example for additional query params #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit 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. WalkthroughA 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
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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_parametersin thetranscribe_urlmethod
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
examples/listen/v1/media/transcribe_url/with_additional_query_parameters.py
Outdated
Show resolved
Hide resolved
…uery_parameters.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
pcgeek86
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this 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
📒 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
| request_options={ | ||
| "additional_query_parameters": { | ||
| "detect_language": ["en", "es"], | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 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 2Repository: 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 -10Repository: 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 -50Repository: 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 -5Repository: 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.pyRepository: 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.
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:
examples/listen/v1/media/transcribe_url/with_additional_query_parameters.pyto show how to transcribe audio from a URL and specify multiple languages for detection using thedetect_languagequery parameter.dotenvlibrary to load environment variables, ensuring credentials and configuration are securely managed.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.