Skip to content
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

ListenWebSocketClient.start failed #493

Open
spencerchubb opened this issue Jan 1, 2025 · 1 comment
Open

ListenWebSocketClient.start failed #493

spencerchubb opened this issue Jan 1, 2025 · 1 comment

Comments

@spencerchubb
Copy link

spencerchubb commented Jan 1, 2025

What is the current behavior?

def init_deepgram():
    def on_message(self, result, **kwargs):
        print("on_message")
        sentence = result.channel.alternatives[0].transcript
        if len(sentence) == 0:
            return
        print(f"Deepgram transcription: {sentence}")

    def on_error(self, error, **kwargs):
        print(f"Deepgram error: {error}")

    config = DeepgramClientOptions(
        api_key=os.getenv("DEEPGRAM_API_KEY"),
        options={"keepalive": "true"},
    )
    deepgram = DeepgramClient(config)
    dg_connection = deepgram.listen.websocket.v("1")
    dg_connection.on(LiveTranscriptionEvents.Transcript, on_message)
    dg_connection.on(LiveTranscriptionEvents.Error, on_error)

    options = LiveOptions(
        punctuate=True,
        language="en-US",
        vad_events=True,
    )
    return dg_connection.start(options)

init_deepgram()
WebSocketException in AbstractSyncWebSocketClient.start: server rejected WebSocket connection: HTTP 401
ListenWebSocketClient.start failed

Expected behavior

I expect it to open the websocket connection successfully

Please tell us about your environment

OS: Tried on Windows and Windows Subsystem for Linux, failed on both
Python version: Python 3.10.12
deepgram-sdk 3.7.7
websockets 13.1

Anything else we should know

I know that I'm populating the API key correctly because I tried printing it out

@spencerchubb
Copy link
Author

I found a workaround for the above issue, but found what seems to be another bug

I had to pass in the api key to DeepgramClient. It did NOT work if I pass in api key to DeepgramClientOptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant