Use Cases
Speech Translation
This script demonstrates the integration of real-time Speech-to-Text (STT) and Machine Translation (NMT) using the Reverie SDK. It captures audio input from a microphone, converts the speech into text using the Reverie ASR service, and then translates the transcribed text into a target language using Reverie NMT.
Install Dependencies
How does it Works?
The script follows these main steps:
- Environment Setup:
The script loads the required credentials (REVERIE_APP_ID and REVERIE_API_KEY) from environment variables using the dotenv library. These credentials are essential for authenticating API requests to the Reverie SDK.
Python
- Real-Time Audio Streaming:
The script uses pyaudio to capture audio from the microphone in real-time. The captured audio is sent to the Reverie ASR service for continuous transcription via the AudioStream object. The audio data is streamed asynchronously, providing live transcription results.
Python
- Speech-to-Text (STT) Conversion:
The captured audio is processed by the Reverie ASR service, which transcribes the spoken words into text. The transcription happens in real-time, and each segment of the transcribed text is displayed as it is received.
Python
- Callback Function for ASR Results:
A callback function is used to handle the ASR responses. Once the transcription is finalized, the transcribed text is returned and printed.
Python
- Text Translation:
After obtaining the transcribed text, the script sends it to the Reverie NMT service for translation into the specified target language (e.g., from Hindi to English in this case). The translation result is then printed.
Python
- Error Handling:
Comprehensive error handling is included to ensure smooth operation, including managing microphone input errors and any potential issues during the transcription or translation processes.
Python