Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
786 changes: 635 additions & 151 deletions README.md

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions examples/speech-to-text/rest/sync/url/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this updated URL example, as the older one was a bit limited in functionality. You can see what I removed below.

# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
# SPDX-License-Identifier: MIT

import os
from dotenv import load_dotenv
import logging
from deepgram.utils import verboselogs
from datetime import datetime
import httpx

from deepgram import (
DeepgramClient,
DeepgramClientOptions,
PrerecordedOptions,
UrlSource,
)

load_dotenv()

# URL to the audio file to transcribe
AUDIO_URL = "https://dpgr.am/spacewalk.wav" # Replace with your audio URL


def main():
try:
# STEP 1 Create a Deepgram client using the API key in the environment variables
config: DeepgramClientOptions = DeepgramClientOptions(
verbose=verboselogs.SPAM,
)
deepgram: DeepgramClient = DeepgramClient("", config)
# OR use defaults
# deepgram: DeepgramClient = DeepgramClient()

# STEP 2 Call the transcribe_url method on the rest class
payload: UrlSource = {
"url": AUDIO_URL,
}

options: PrerecordedOptions = PrerecordedOptions(
model="nova-3",
smart_format=True,
)

before = datetime.now()
response = deepgram.listen.rest.v("1").transcribe_url(
payload, options, timeout=httpx.Timeout(300.0, connect=10.0)
)
after = datetime.now()

print(response.to_json(indent=4))
print("")
difference = after - before
print(f"time: {difference.seconds}")

except Exception as e:
print(f"Exception: {e}")


if __name__ == "__main__":
main()
47 changes: 0 additions & 47 deletions examples/speech-to-text/rest/url/main.py

This file was deleted.