Home Python - Streaming audio to Google Cloud silently failling
Reply: 0

Python - Streaming audio to Google Cloud silently failling

Juanvulcano Published in 2017-12-04 10:29:14Z

I am trying to stream audio in a Int16 array format from Flask server to Google Cloud Speech Api. For some reason it's silently failing, probably it has something to do with how I'm using the stream generator or sending the data in a wrong forma

Google Cloud Documentation says that stream should be a generator yielding chunks of audio data. Not very explicit, I tried building a generator.

Why I'm not getting response from google cloud?

This is the main code

def audio(ws):
    total_msg = ""
    sample_rate = 16000
    while True:
        def generator():
            msg = ws.receive()                  
            if msg is not None:
                audio_as_int_array = numpy.frombuffer(msg, 'i2')
        stream = [generator()]
        requests = (types.StreamingRecognizeRequest(audio_content=chunk)
                for chunk in stream)
        language_code = 'en-US'  # a BCP-47 language tag
        client = speech.SpeechClient()
        config = types.RecognitionConfig(
        streaming_config = types.StreamingRecognitionConfig(
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.292867 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO