-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy path12-transcription-prerecorded-callback.py
More file actions
35 lines (26 loc) · 1.07 KB
/
12-transcription-prerecorded-callback.py
File metadata and controls
35 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Example: Transcribe Prerecorded Audio with Callback
This example shows how to transcribe audio asynchronously using a callback URL.
The transcription result will be sent to your callback URL when ready.
"""
from dotenv import load_dotenv
load_dotenv()
from deepgram import DeepgramClient
client = DeepgramClient()
try:
print("Sending transcription request with callback...")
response = client.listen.v1.media.transcribe_url(
url="https://dpgr.am/spacewalk.wav",
callback="https://your-callback-url.com/webhook",
model="nova-3",
)
# This returns a "listen accepted" response, not the full transcription
# The actual transcription will be sent to your callback URL
print(f"Request accepted. Request ID: {response.request_id}")
print("Transcription will be sent to your callback URL when ready.")
# For async version:
# from deepgram import AsyncDeepgramClient
# client = AsyncDeepgramClient()
# response = await client.listen.v1.media.transcribe_url(..., callback="...")
except Exception as e:
print(f"Error: {e}")