Skip to content

Instantly share code, notes, and snippets.

@henriqueutsch
Created May 4, 2015 22:30
Show Gist options
  • Save henriqueutsch/e3a5c1afd774bf13d41f to your computer and use it in GitHub Desktop.
Save henriqueutsch/e3a5c1afd774bf13d41f to your computer and use it in GitHub Desktop.
Salva isso como mp3
http://www.receita.fazenda.gov.br/pessoajuridica/cnpj/cnpjreva/captcha/gerarSom.asp
Converte pra flac
http://stackoverflow.com/questions/18266785/sox-for-converting-flac-file-to-320-bit-mp3
sox input.mp3 output.flac
Envia para google speech e recebe um json
require 'json'
require 'net/http'
require 'uri'
def nethttp()
url = "https://www.google.com/speech-api/v2/recognize?output=json&lang=pt-BR&key=apikey"
uri = URI.parse(url);
http = Net::HTTP.new(uri.host)
request = Net::HTTP::Post.new(uri.request_uri)
request.body = File.open('test.flac','rb').read
request.content_type = 'audio/x-flac; rate=16000'
res = http.request(request)
# p res.body
return res.body
end
p nethttp()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment