The following example demonstrates how to interact with the Google ASR API:
Copy
Ask AI
from om1_speech import AudioInputStream# Initialize the Google ASR APIws_client = ws.Client(url="wss://api.openmind.org/api/core/google/asr?api_key=<YOUR_API_KEY>")audio_stream_input = AudioInputStream(audio_data_callback=ws_client.send_message)# Start the Google ASR APIws_client.start()audio_stream_input.start()# Retrieve the Google ASR API responsews_client.register_message_callback(lambda msg: print(msg))while True: time.sleep(1)
The expected response from the Google ASR API will be in the following format:
Copy
Ask AI
{ "asr_reply": "hello world"}
You can also forward the base64 encoded audio data directly to the API endpoint: