Skip to content

Commit ab9bd47

Browse files
WMS ID 9001: Update sdk version, imports and listed additional steps in md file (#387)
update sdk version, imports and listed additional steps in md file for the same
1 parent feabec1 commit ab9bd47

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

oci-artificial-intelligence/ai-speech/transcribe-live-audio/files/realtime_example.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from oci.config import from_file
66
from oci.auth.signers.security_token_signer import SecurityTokenSigner
77

8-
from oci.ai_speech_realtime import (
8+
from oci_ai_speech_realtime import (
99
RealtimeSpeechClient,
1010
RealtimeSpeechClientListener
1111
)
@@ -109,6 +109,9 @@ def on_network_event(self, ackmessage):
109109

110110
def on_error(self):
111111
return super().on_error()
112+
113+
def on_close(self, error_code, error_message):
114+
return super().on_close(error_code, error_message)
112115

113116

114117
if __name__ == "__main__":
@@ -123,7 +126,7 @@ def message_callback(message):
123126
)
124127
realtime_speech_parameters.partial_silence_threshold_in_ms = 0
125128
realtime_speech_parameters.final_silence_threshold_in_ms = 2000
126-
# realtime_speech_parameters.encoding="audio/raw;rate=16000"
129+
realtime_speech_parameters.encoding="audio/raw;rate=16000"
127130
realtime_speech_parameters.punctuation = (
128131
realtime_speech_parameters.PUNCTUATION_AUTO
129132
)
@@ -146,7 +149,7 @@ def message_callback(message):
146149
# }
147150
# ]
148151

149-
realtime_speech_url = "wss://realtime.aiservice-preprod.ap-sydney-1.oci.oraclecloud.com"
152+
realtime_speech_url = "wss://realtime.aiservice.uk-london-1.oci.oraclecloud.com"
150153
client = RealtimeSpeechClient(
151154
realtime_speech_parameters=realtime_speech_parameters,
152155
config=config,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PyAudio>=0.2.14
2+
oci-ai-speech-realtime>=2.1.0

oci-artificial-intelligence/ai-speech/transcribe-live-audio/transcribe-live-audio.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ First, refer to lab 4 (Access OCI speech with OCI SDKs (Optional)) for API signi
8282

8383
Click [here](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdks.htm) for documentation regarding AI Speech SDK
8484

85+
Along with the OCI SDK, install the OCI AI Speech live transcription SDK:
86+
87+
```
88+
pip install oci-ai-speech-realtime
89+
```
90+
91+
To allow recording and streaming of audio install the PyAudio package:
92+
93+
```
94+
pip install pyaudio>=0.2.14
95+
```
96+
97+
Alternatively, both the required packages can be installed using the `requirements.txt` present [here](./files/requirements.txt):
98+
```
99+
pip install -r requirements.txt
100+
```
101+
85102
OCI AI Speech live transcription uses websockets to relay audio data and receive text transcriptions in real time. This means your client must implement some key listener functions:
86103

87104
<strong>Python example:</strong>
@@ -178,7 +195,7 @@ class MyRealtimeListener(RealtimeClientListener):
178195

179196
`model_domain` : <strong>"GENERIC"</strong>
180197

181-
`partial_silence_threshold_in_ms` : <strong>500</strong>
198+
`partial_silence_threshold_in_ms` : <strong>0</strong>
182199

183200
`final_silence_threshold_in_ms` : <strong>2000</strong>
184201

0 commit comments

Comments
 (0)