@@ -118,12 +118,17 @@ deepgram = DeepgramClient("YOUR_API_KEY") # Replace with your API key
118118Transcribe audio from a URL.
119119
120120``` python
121+ from deepgram import PrerecordedOptions, UrlSource
121122
122- from deepgram import PrerecordedOptions
123+ payload: UrlSource = {
124+ " url" : " https://dpgr.am/spacewalk.wav"
125+ }
126+
127+ options = PrerecordedOptions(model = " nova-3" ) # Apply other options
123128
124129response = deepgram.listen.rest.v(" 1" ).transcribe_url(
125- source = { " url " : " https://dpgr.am/spacewalk.wav " } ,
126- options = PrerecordedOptions( model = " nova-3 " ) # Apply other options
130+ payload ,
131+ options
127132)
128133```
129134
@@ -134,11 +139,20 @@ response = deepgram.listen.rest.v("1").transcribe_url(
134139Transcribe audio from a file.
135140
136141``` python
137- from deepgram import PrerecordedOptions
142+ from deepgram import PrerecordedOptions, FileSource
143+
144+ with open (" path/to/your/audio.wav" , " rb" ) as file :
145+ buffer_data = file .read()
146+
147+ payload: FileSource = {
148+ " buffer" : buffer_data,
149+ }
150+
151+ options = PrerecordedOptions(model = " nova-3" ) # Apply other options
138152
139153response = deepgram.listen.rest.v(" 1" ).transcribe_file(
140- source = open ( " path/to/your/audio.wav " , " rb " ) ,
141- options = PrerecordedOptions( model = " nova-3 " ) # Apply other options
154+ payload ,
155+ options
142156)
143157```
144158
@@ -151,12 +165,18 @@ response = deepgram.listen.rest.v("1").transcribe_file(
151165Transcribe audio from a URL.
152166
153167``` python
154- from deepgram import PrerecordedOptions
168+ from deepgram import PrerecordedOptions, UrlSource
169+
170+ payload: UrlSource = {
171+ " url" : " https://dpgr.am/spacewalk.wav"
172+ }
173+
174+ options = PrerecordedOptions(model = " nova-3" ) # Apply other options
155175
156- response = deepgram.listen.rest.v(" 1" ).transcribe_url_async (
157- source = { " url " : " https://dpgr.am/spacewalk.wav " } ,
158- callback_url = " https://your-callback-url.com/webhook" ,
159- options = PrerecordedOptions( model = " nova-3 " ) # Apply other options
176+ response = deepgram.listen.rest.v(" 1" ).transcribe_url_callback (
177+ payload ,
178+ " https://your-callback-url.com/webhook" ,
179+ options = options
160180)
161181```
162182
@@ -167,12 +187,21 @@ response = deepgram.listen.rest.v("1").transcribe_url_async(
167187Transcribe audio from a file.
168188
169189``` python
170- from deepgram import PrerecordedOptions
190+ from deepgram import PrerecordedOptions, FileSource
191+
192+ with open (" path/to/your/audio.wav" , " rb" ) as file :
193+ buffer_data = file .read()
194+
195+ payload: FileSource = {
196+ " buffer" : buffer_data,
197+ }
198+
199+ options = PrerecordedOptions(model = " nova-3" ) # Apply other options
171200
172- response = deepgram.listen.rest.v(" 1" ).transcribe_file_async (
173- source = open ( " path/to/your/audio.wav " , " rb " ) ,
174- callback_url = " https://your-callback-url.com/webhook" ,
175- options = PrerecordedOptions( model = " nova-3 " ) # Apply other options
201+ response = deepgram.listen.rest.v(" 1" ).transcribe_file_callback (
202+ payload ,
203+ " https://your-callback-url.com/webhook" ,
204+ options = options
176205)
177206```
178207
@@ -347,18 +376,25 @@ connection.finish()
347376Analyze text.
348377
349378``` python
350- from deepgram import ReadOptions
379+ from deepgram import AnalyzeOptions, TextSource
351380
352- # Configure read options
353- options = ReadOptions(
354- model = " nova-3" ,
355- language = " en"
381+ # Configure analyze options
382+ options = AnalyzeOptions(
383+ sentiment = True ,
384+ intents = True ,
385+ topics = True ,
386+ summarize = True
356387)
357388
389+ # Create text source
390+ payload: TextSource = {
391+ " buffer" : " The quick brown fox jumps over the lazy dog."
392+ }
393+
358394# Process text for intelligence
359- response = deepgram.read.rest .v(" 1" ).process (
360- text = " The quick brown fox jumps over the lazy dog. " ,
361- options = options
395+ response = deepgram.read.analyze .v(" 1" ).analyze_text (
396+ payload ,
397+ options
362398)
363399```
364400
0 commit comments