Class: VoiceRecognitionBing::MSService
- Inherits:
-
Object
- Object
- VoiceRecognitionBing::MSService
- Defined in:
- lib/voice_recognition_bing/ms_service.rb
Class Method Summary collapse
Class Method Details
.authenticate(subscription_key:) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/voice_recognition_bing/ms_service.rb', line 8 def authenticate(subscription_key:) response = HTTParty.post( "https://api.cognitive.microsoft.com/sts/v1.0/issueToken", { headers: {"Ocp-Apim-Subscription-Key" => subscription_key } } ) response.body end |
.recognize(content:, token:) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/voice_recognition_bing/ms_service.rb', line 18 def recognize(content:, token:) url = 'https://speech.platform.bing.com/recognize?version=3.0' + "&requestid=#{SecureRandom.uuid}" + "&appID=#{SecureRandom.uuid}" + "&instanceid=#{SecureRandom.uuid}" + '&format=json&locale=es-ES&device.os=linux&scenarios=ulm' opts = { headers: {"Authorization" => "Bearer #{token}", "Content-Type" => "audio/wav; codec=audio/pcm; samplerate=16000; sourcerate=8000; trustsourcerate=false" }, body: content.to_s } HTTParty.post(url, opts).body end |