Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speech Stream isn't completely understandable. #122

Closed
frankyn opened this issue Nov 21, 2016 · 1 comment
Closed

Speech Stream isn't completely understandable. #122

frankyn opened this issue Nov 21, 2016 · 1 comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@frankyn
Copy link
Member

frankyn commented Nov 21, 2016

Context: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/v0.22.0/google/cloud/speech/project?method=stream-instance

I'm not sure what the correct sending rate is given a sample size of 44100Hz with 16bit rate. I was informed to send 88200 bytes per second, and I also tried brute forcing different values. The error message doesn't help and additional information in the error message would be helpful. Such as, how to better calibrate the transmission rate given a sample rate and encoding. I want to note that I used the data in audio.grpc.content as the payload.

Any help would be appreciated! Thank you.

Error:
11:Audio data is being streamed too fast. Please stream audio data approximately at real time.

Code:

require 'google/cloud/speech'

# Stream to speech and wait for transcription... 
speech = Google::Cloud::Speech.new

# Setup raw file to be sent in as an Asynchronous job maximum time is ~80mins
audio = speech.audio "prince.raw",
                      encoding: :raw, sample_rate: 44100,
                      language: :ja 

# Send stream job
stream = speech.stream encoding: :raw, sample_rate: 44100, language: 'ja'

# Result callback
stream.on_result do |results|
  result = results.first
  puts result.transcript
end

# Error callback
stream.on_error do |error|
  puts error
end

# Start callback
stream.on_speech_start do 
  puts "Started listening"
end

# Complete callback
stream.on_complete do
  puts "Finished"
end

bytes_sent = 0
chunk_size = 88200
bytes_total = audio.grpc.content.size # Content of my raw file (This may be wrong)..

# Send one chunk per second 
while bytes_sent < bytes_total do 
  stream.send audio.grpc.content[bytes_sent, (bytes_sent + chunk_size)]
  bytes_sent += chunk_size 
  sleep 1
end

# Finished sending
stream.complete!

# Stop stream
stream.stop
@frankyn
Copy link
Member Author

frankyn commented Nov 21, 2016

Wrong location to submit issue...

@frankyn frankyn closed this as completed Nov 21, 2016
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants