generated from deepgram/oss-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 84
feat: support arbitrary attributes for speak provider #532
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
Open
naomi-lgbt
wants to merge
2
commits into
main
Choose a base branch
from
feat/generic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -342,7 +342,6 @@ | |
Listen, | ||
ListenProvider, | ||
Speak, | ||
SpeakProvider, | ||
Header, | ||
Item, | ||
Properties, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,7 +356,6 @@ | |
Listen, | ||
ListenProvider, | ||
Speak, | ||
SpeakProvider, | ||
Header, | ||
Item, | ||
Properties, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,7 +365,6 @@ | |
Listen, | ||
ListenProvider, | ||
Speak, | ||
SpeakProvider, | ||
Header, | ||
Item, | ||
Properties, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,6 @@ | |
Listen, | ||
ListenProvider, | ||
Speak, | ||
SpeakProvider, | ||
Header, | ||
Item, | ||
Properties, | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,6 @@ | |
Listen, | ||
ListenProvider, | ||
Speak, | ||
SpeakProvider, | ||
Header, | ||
Item, | ||
Properties, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,6 @@ | |
Listen, | ||
ListenProvider, | ||
Speak, | ||
SpeakProvider, | ||
Header, | ||
Item, | ||
Properties, | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Copyright 2025 Deepgram SDK contributors. All Rights Reserved. | ||
# Use of this source code is governed by a MIT license that can be found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Import dependencies and set up the main function | ||
import requests | ||
import wave | ||
import io | ||
import time | ||
import os | ||
import json | ||
import threading | ||
from datetime import datetime | ||
|
||
from deepgram import ( | ||
DeepgramClient, | ||
DeepgramClientOptions, | ||
AgentWebSocketEvents, | ||
AgentKeepAlive, | ||
) | ||
from deepgram.clients.agent.v1.websocket.options import SettingsOptions | ||
|
||
def main(): | ||
try: | ||
# Initialize the Voice Agent | ||
api_key = os.getenv("DEEPGRAM_API_KEY") | ||
if not api_key: | ||
raise ValueError("DEEPGRAM_API_KEY environment variable is not set") | ||
print(f"API Key found:") | ||
|
||
# Initialize Deepgram client | ||
config = DeepgramClientOptions( | ||
options={ | ||
"keepalive": "true", | ||
# "speaker_playback": "true", | ||
}, | ||
) | ||
deepgram = DeepgramClient(api_key, config) | ||
connection = deepgram.agent.websocket.v("1") | ||
print("Created WebSocket connection...") | ||
|
||
# 4. Configure the Agent | ||
options = SettingsOptions() | ||
# Audio input configuration | ||
options.audio.input.encoding = "linear16" | ||
options.audio.input.sample_rate = 24000 | ||
# Audio output configuration | ||
options.audio.output.encoding = "linear16" | ||
options.audio.output.sample_rate = 24000 | ||
options.audio.output.container = "wav" | ||
# Agent configuration | ||
options.agent.language = "en" | ||
options.agent.listen.provider.type = "deepgram" | ||
options.agent.listen.provider.model = "nova-3" | ||
options.agent.think.provider.type = "open_ai" | ||
options.agent.think.provider.model = "gpt-4o-mini" | ||
options.agent.think.prompt = "You are a friendly AI assistant." | ||
options.agent.speak.provider.type = "deepgram" | ||
options.agent.speak.provider.model = "aura-2-thalia-en" | ||
options.agent.greeting = "Hello! How can I help you today?" | ||
options.agent.speak.provider.arbitrary_key = "test" | ||
|
||
def on_welcome(self, welcome, **kwargs): | ||
print(f"Welcome message received: {welcome}") | ||
with open("chatlog.txt", 'a') as chatlog: | ||
chatlog.write(f"Welcome message: {welcome}\n") | ||
|
||
def on_settings_applied(self, settings_applied, **kwargs): | ||
print(f"Settings applied: {settings_applied}") | ||
with open("chatlog.txt", 'a') as chatlog: | ||
chatlog.write(f"Settings applied: {settings_applied}\n") | ||
|
||
def on_error(self, error, **kwargs): | ||
print(f"Error received: {error}") | ||
with open("chatlog.txt", 'a') as chatlog: | ||
chatlog.write(f"Error: {error}\n") | ||
|
||
# Register handlers | ||
connection.on(AgentWebSocketEvents.Welcome, on_welcome) | ||
connection.on(AgentWebSocketEvents.SettingsApplied, on_settings_applied) | ||
connection.on(AgentWebSocketEvents.Error, on_error) | ||
print("Event handlers registered") | ||
|
||
# Start the connection | ||
print("Starting WebSocket connection...") | ||
print(options) | ||
if not connection.start(options): | ||
print("Failed to start connection") | ||
return | ||
print("WebSocket connection started successfully") | ||
|
||
# Cleanup | ||
connection.finish() | ||
print("Finished") | ||
|
||
except Exception as e: | ||
print(f"Error: {str(e)}") | ||
|
||
if __name__ == "__main__": | ||
main() |
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.
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.
I was thinking of something along the lines of