I'm trying to understand google speech to text sample, it takes data from micro and convert the audio to text
Whole source code is here https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/microphone/transcribe_streaming_mic.py#L181
generator will yield some data
def generator(self):
while not self.closed:
#.....
yield b''.join(data)
audio_generator = stream.generator()
requests = (types.StreamingRecognizeRequest(audio_content=content)
for content in audio_generator)
responses = client.streaming_recognize(streaming_config, requests)
listen_print_loop(responses)
I only know little about python, cannot understand above code, seems generator will not block if some data is yield.
What does the for .. in
line mean?
If the audio data comes for ever the for loop
will run forever? and when will client.streaming_recognize
gets run?
===UPDATE
OK, now I know generator..
but still does not understand for in line, does it mean:
for content in audio_generator:
requests = types.StreamingRecognizeRequest(audio_content=content)
?