0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
This is a gem to call the google speech api.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 0
>= 0
 Project Readme

GoogleSpeech

Build Status

This is a gem to call the google speech api.

The gem expects pcm wav audio.

It returns JSON including confidence values, and timing (acts as amkind of transcription alignment).

It uses excon for the http communication, sox (http://sox.sourceforge.net/) for audio conversion and splitting, and the related soxi executable to get audio file info/length.

Inspired by https://github.com/taf2/speech2text

Installation

Add this line to your application's Gemfile:

gem 'google_speech'

And then execute:

$ bundle

Or install it yourself as:

$ gem install google_speech

Usage

As a gem in your code:

require 'google_speech'

f = File.open '/Users/you/Downloads/audio.wav'
transcriber = GoogleSpeech::Transcriber.new(f)
t = transcriber.transcribe

As a command line tool

> google_speech somefile.wav

Options:

  • language - what language is the speech in
  • chunk_duration - length in seconds for each audio chunk of the wav to send
  • overlap - chunking does not respect word boundaries; overlap can compensate
  • max_results - # of results to request of speech api
  • request_pause - sleep seconds between chunk transcription requests
  • profanity_filter - google by default filters profanity; this gem does not.

Default option values:

{
	:language         => 'en-US',
	:chunk_duration   => 8,
	:overlap          => 1,
	:max_results      => 2,
	:request_pause    => 1,
	:profanity_filter => false
}

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request