Skip to content

Commit 7e39230

Browse files
Update Examples Using Latest Class Names
1 parent ead933b commit 7e39230

File tree

26 files changed

+60
-104
lines changed

26 files changed

+60
-104
lines changed

examples/advanced/prerecorded/direct_invocation/main.py renamed to examples/advanced/rest/direct_invocation/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from deepgram.utils import verboselogs
99
import traceback
1010

11-
from deepgram import ClientOptionsFromEnv, PrerecordedOptions, PreRecordedClient
11+
from deepgram import ClientOptionsFromEnv, PrerecordedOptions, ListenRESTClient
1212

1313
load_dotenv()
1414

@@ -19,13 +19,13 @@
1919

2020
def main():
2121
try:
22-
# STEP 1 Create a Deepgram PreRecordedClient using a specific config
22+
# STEP 1 Create a Deepgram ListenRESTClient using a specific config
2323
# config: ClientOptionsFromEnv = ClientOptionsFromEnv(
2424
# verbose=verboselogs.NOTICE,
2525
# )
26-
# asyncClient: PreRecordedClient = PreRecordedClient(config)
26+
# asyncClient: ListenRESTClient = ListenRESTClient(config)
2727
# OR just use the default config
28-
asyncClient: PreRecordedClient = PreRecordedClient(ClientOptionsFromEnv())
28+
asyncClient: ListenRESTClient = ListenRESTClient(ClientOptionsFromEnv())
2929

3030
# STEP 2 Call the transcribe_url method on the prerecorded class
3131
options: PrerecordedOptions = PrerecordedOptions(

examples/advanced/streaming/direct_invocation/main.py renamed to examples/advanced/websocket/direct_invocation/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import threading
1010

1111
from deepgram import (
12-
LiveClient,
12+
ListenWebSocketClient,
1313
ClientOptionsFromEnv,
1414
LiveTranscriptionEvents,
1515
LiveOptions,
@@ -23,13 +23,15 @@
2323

2424
def main():
2525
try:
26-
# STEP 1 Create a Deepgram LiveClient using a specific config
26+
# STEP 1 Create a Deepgram ListenWebSocketClient using a specific config
2727
# config: ClientOptionsFromEnv = ClientOptionsFromEnv(
2828
# verbose=verboselogs.DEBUG, options={"keepalive": "true"}
2929
# )
30-
# liveClient: LiveClient = LiveClient("", config)
30+
# liveClient: ListenWebSocketClient = ListenWebSocketClient("", config)
3131
# OR just use the default config
32-
liveClient: LiveClient = LiveClient(ClientOptionsFromEnv())
32+
liveClient: ListenWebSocketClient = ListenWebSocketClient(
33+
ClientOptionsFromEnv()
34+
)
3335

3436
def on_message(self, result, **kwargs):
3537
sentence = result.channel.alternatives[0].transcript

examples/advanced/streaming/microphone_inheritance/main.py renamed to examples/advanced/websocket/microphone_inheritance/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from deepgram import (
1111
ClientOptionsFromEnv,
1212
LiveTranscriptionEvents,
13-
LiveClient,
13+
ListenWebSocketClient,
1414
LiveOptions,
1515
Microphone,
1616
LiveResultResponse,
@@ -24,8 +24,8 @@
2424

2525

2626
# more complex example
27-
class MyLiveClient(LiveClient):
28-
def __init__(self, config: LiveClient):
27+
class MyLiveClient(ListenWebSocketClient):
28+
def __init__(self, config: ListenWebSocketClient):
2929
super().__init__(config)
3030
super().on(LiveTranscriptionEvents.Transcript, self.on_message)
3131
super().on(LiveTranscriptionEvents.Metadata, self.on_metadata)

examples/speech-to-text/rest/async_url/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
deepgram: DeepgramClient = DeepgramClient(API_KEY)
2626

2727

28-
# STEP 2 Call the transcribe_url method on the prerecorded class
28+
# STEP 2 Call the transcribe_url method on the rest class
2929
async def transcribe_url():
30-
url_response = await deepgram.listen.asyncprerecorded.v("1").transcribe_url(
30+
url_response = await deepgram.listen.asyncrest.v("1").transcribe_url(
3131
AUDIO_URL, options
3232
)
3333
return url_response

examples/speech-to-text/rest/callback/callback/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def main():
3333

3434
deepgram: DeepgramClient = DeepgramClient("", config)
3535

36-
# STEP 2 Call the transcribe_file method on the prerecorded class
36+
# STEP 2 Call the transcribe_file method on the rest class
3737
with open(AUDIO_FILE, "rb") as file:
3838
buffer_data = file.read()
3939

@@ -51,11 +51,11 @@ def main():
5151
utterances=True,
5252
)
5353

54-
response = deepgram.listen.prerecorded.v("1").transcribe_file_callback(
54+
response = deepgram.listen.rest.v("1").transcribe_file_callback(
5555
payload, CALL_BACK_URL, options=options
5656
)
5757
# For URL hosted audio files, comment out the above and uncomment the below
58-
# response = deepgram.listen.prerecorded.v("1").transcribe_url_callback(
58+
# response = deepgram.listen.rest.v("1").transcribe_url_callback(
5959
# payload, CALL_BACK_URL, options=options
6060
# )
6161
print(response.to_json(indent=4))

examples/speech-to-text/rest/file/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def main():
3131
# OR use defaults
3232
# deepgram: DeepgramClient = DeepgramClient()
3333

34-
# STEP 2 Call the transcribe_file method on the prerecorded class
34+
# STEP 2 Call the transcribe_file method on the rest class
3535
with open(AUDIO_FILE, "rb") as file:
3636
buffer_data = file.read()
3737

@@ -48,7 +48,7 @@ def main():
4848
)
4949

5050
before = datetime.now()
51-
response = deepgram.listen.prerecorded.v("1").transcribe_file(
51+
response = deepgram.listen.rest.v("1").transcribe_file(
5252
payload, options, timeout=httpx.Timeout(300.0, connect=10.0)
5353
)
5454
after = datetime.now()

examples/speech-to-text/rest/intent/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def main():
3030
# OR use defaults
3131
deepgram: DeepgramClient = DeepgramClient()
3232

33-
# STEP 2 Call the transcribe_file method on the prerecorded class
33+
# STEP 2 Call the transcribe_file method on the rest class
3434
with open(AUDIO_FILE, "rb") as file:
3535
buffer_data = file.read()
3636

@@ -47,7 +47,7 @@ def main():
4747
)
4848

4949
before = datetime.now()
50-
response = deepgram.listen.prerecorded.v("1").transcribe_file(payload, options)
50+
response = deepgram.listen.rest.v("1").transcribe_file(payload, options)
5151
after = datetime.now()
5252

5353
print(response.to_json(indent=4))

examples/speech-to-text/rest/legacy_dict_url/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ def main():
2525
# STEP 1 Create a Deepgram client using the API key from environment variables
2626
deepgram = DeepgramClient("", ClientOptionsFromEnv())
2727

28-
# STEP 2 Call the transcribe_url method on the prerecorded class
28+
# STEP 2 Call the transcribe_url method on the rest class
2929
options = {
3030
"mode": "nova-2",
3131
"smart_format": True,
3232
}
33-
response = deepgram.listen.prerecorded.v("1").transcribe_url(AUDIO_URL, options)
33+
response = deepgram.listen.rest.v("1").transcribe_url(AUDIO_URL, options)
3434
print(f"response: {response}\n\n")
3535
# print(f"metadata: {response['metadata']}\n\n")
3636
# print(

0 commit comments

Comments
 (0)