lib/google/cloud/speech/stream.rb in google-cloud-speech-0.21.0 vs lib/google/cloud/speech/stream.rb in google-cloud-speech-0.21.1
- old
+ new
@@ -29,22 +29,22 @@
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
- # stream = audio.stream encoding: :raw, sample_rate: 16000
+ # stream = speech.stream encoding: :raw, sample_rate: 16000
#
# # register callback for when a result is returned
# stream.on_result do |results|
# result = results.first
# puts result.transcript # "how old is the Brooklyn Bridge"
# puts result.confidence # 0.9826789498329163
# end
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop
#
@@ -91,22 +91,24 @@
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
+ # audio = speech.audio "path/to/audio.raw"
+ #
# stream = speech.stream encoding: :raw, sample_rate: 16000
#
# # register callback for when a result is returned
# stream.on_result do |results|
# result = results.first
# puts result.transcript # "how old is the Brooklyn Bridge"
# puts result.confidence # 0.9826789498329163
# end
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop
#
@@ -149,24 +151,25 @@
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
- # stream = audio.stream encoding: :raw, sample_rate: 16000
+ # stream = speech.stream encoding: :raw, sample_rate: 16000
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop
#
# results = stream.results
- # result = results.first
- # puts result.transcript # "how old is the Brooklyn Bridge"
- # puts result.confidence # 0.9826789498329163
+ # results.each do |result|
+ # puts result.transcript
+ # puts result.confidence
+ # end
#
def results
synchronize do
@results
end
@@ -182,23 +185,23 @@
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
- # stream = audio.stream encoding: :raw, sample_rate: 16000
+ # stream = speech.stream encoding: :raw, sample_rate: 16000
#
# # register callback for when an interim result is returned
# stream.on_interim do |final_results, interim_results|
# interim_result = interim_results.first
# puts interim_result.transcript # "how old is the Brooklyn Bridge"
# puts interim_result.confidence # 0.9826789498329163
# puts interim_result.stability # 0.8999
# end
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop
#
@@ -225,22 +228,22 @@
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
- # stream = audio.stream encoding: :raw, sample_rate: 16000
+ # stream = speech.stream encoding: :raw, sample_rate: 16000
#
# # register callback for when an interim result is returned
# stream.on_result do |results|
# result = results.first
# puts result.transcript # "how old is the Brooklyn Bridge"
# puts result.confidence # 0.9826789498329163
# end
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop
#
@@ -257,11 +260,11 @@
end
# callback for final result received
result!
end
- # @private yields each final results as they are recieved
+ # @private yields each final results as they are received
def result!
synchronize do
@callbacks[:result].each { |c| c.call results }
end
end
@@ -276,20 +279,20 @@
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
- # stream = audio.stream encoding: :raw, sample_rate: 16000
+ # stream = speech.stream encoding: :raw, sample_rate: 16000
#
# # register callback for when speech has started.
# stream.on_speech_start do
# puts "Speech has started."
# end
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop
#
@@ -298,11 +301,11 @@
@callbacks[:speech_start] << block
end
end
# @private returns single final result once :END_OF_UTTERANCE is
- # recieved.
+ # received.
def speech_start!
synchronize do
@callbacks[:speech_start].each(&:call)
end
end
@@ -317,20 +320,20 @@
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
- # stream = audio.stream encoding: :raw, sample_rate: 16000
+ # stream = speech.stream encoding: :raw, sample_rate: 16000
#
# # register callback for when speech has ended.
# stream.on_speech_end do
# puts "Speech has ended."
# end
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop
#
@@ -339,11 +342,11 @@
@callbacks[:speech_end] << block
end
end
# @private yields single final result once :END_OF_UTTERANCE is
- # recieved.
+ # received.
def speech_end!
synchronize do
@callbacks[:speech_end].each(&:call)
end
end
@@ -358,20 +361,20 @@
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
- # stream = audio.stream encoding: :raw, sample_rate: 16000
+ # stream = speech.stream encoding: :raw, sample_rate: 16000
#
# # register callback for when audio has ended.
# stream.on_complete do
# puts "Audio has ended."
# end
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop
#
@@ -403,23 +406,23 @@
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
- # stream = audio.stream encoding: :raw,
- # sample_rate: 16000,
- # utterance: true
+ # stream = speech.stream encoding: :raw,
+ # sample_rate: 16000,
+ # utterance: true
#
# # register callback for when utterance has occurred.
# stream.on_utterance do
# puts "Utterance has occurred."
# stream.stop
# end
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop unless stream.stopped?
#
@@ -428,38 +431,38 @@
@callbacks[:utterance] << block
end
end
# @private returns single final result once :END_OF_UTTERANCE is
- # recieved.
+ # received.
def utterance!
synchronize do
@callbacks[:utterance].each(&:call)
end
end
##
- # Register to be notified of an error recieved during the stream.
+ # Register to be notified of an error received during the stream.
#
# @yield [callback] The block for accessing final results.
# @yieldparam [Exception] error The error raised.
#
# @example
# require "google/cloud/speech"
#
# speech = Google::Cloud::Speech.new
#
- # stream = audio.stream encoding: :raw, sample_rate: 16000
+ # stream = speech.stream encoding: :raw, sample_rate: 16000
#
# # register callback for when an error is returned
# stream.on_error do |error|
# puts "The following error occurred while streaming: #{error}"
# stream.stop
# end
#
- # # Stream 5 seconds of audio from the microhone
+ # # Stream 5 seconds of audio from the microphone
# # Actual implementation of microphone input varies by platform
- # 5.times.do
+ # 5.times do
# stream.send MicrophoneInput.read(32000)
# end
#
# stream.stop
#