Code Monkey home page Code Monkey logo

watson-streaming-localfile-stt's Introduction

THIS CODE IS MODIFIED IN ORDER TO PERFORM STREAMING SPEECH RECOGNITION ON LOCAL FILE ===================================================

In order to recognize your local audio file, Change a variable named 'PATH' on trancribe.py into your file path.

It shows a time taken to receive a final result of speech recognition.

Expected Output

$ python transcribe.py
Transcript:이러한 감정도 오면은 유대감을 더 강하게 만든다 
Latency: 3.3767147064208984 sec

ORIGINAL README: Watson Streaming Speech to Text Example ============================

The following is an example of using Watson to real time transcribe from Speech to Text using the websockets streaming API.

Installation

This code is designed to run under python3 in a virtualenv. In order to get started you need to run the following:

virtualenv -p python3 .venv
source .venv/bin/activate
pip install -r requirements.txt

That will build you a clean environment and install the required pyaudio and websockets libraries for it's use.

Getting Started

This uses the pyaudio interface to abstract talking to audio interfaces. On the upside, this smooths over a lot of platform differences.

However, on Linux audio remains a "hard problem". The "default" audio device that is picked up by pyaudio by default is going to be what your sound mixer is set to. In Ubuntu, you will need to go to the Sound settings and set the input to what you want to record from there.

image

Credentials

You'll need to sign up for the Watson STT service. As of Sept 2018, IBM Cloud accounts get 100 minutes / month free.

In order to connect to the Watson streaming server you need an API Key, and to specify which region your speech to text service was provisioned in (there are different gateways per region). You can find these on your IBM Cloud console for the service you have added.

Copy speech.cfg.example to speech.cfg to ensure that's valid.

Expected Output

Once you run transcribe.py with a timeout value (-t) you'll get both incremental output as data comes back, as well as a final stitching of things together. The output will look something like this.

./transcribe.py -t 20
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1041:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2450:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2450:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2450:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1041:(snd_pcm_dmix_open) unable to open slave
* recording
  we
  twinkle
  twinkle twinkle
  twinkle twinkle
  twinkle twinkle
  twinkle twinkle that
  twinkle twinkle little
  twinkle twinkle little
  twinkle twinkle little star
  twinkle twinkle little star
  twinkle twinkle little star
  twinkle twinkle little star I know
  twinkle twinkle little star I know when
  twinkle twinkle little star I know when you're
  twinkle twinkle little star I know when you're
  twinkle twinkle little star I know when you're what you
  twinkle twinkle little star I know when you're what you are
  twinkle twinkle little star I know when you're what you are
  I
  I
  hi herb
  high above
  high above the
  high above them
  high above them we're
  high up above the world so
  high up above the world so
  high up above the world so %HESITATION
  high up above the world so I
  high up above the world so I like
  high up above the world so I like
  high up above the world so I like
  high up above the world so I like die
  high up above the world so I like time and
  high up above the world so I like time and in
  high up above the world so I like time and in those
  high up above the world so I like diamond in the sky
  high up above the world so I like diamond in the sky
  high up above the world so I like diamond in the sky
  high up above the world so I like diamond in the sky
* done recording
  twinkle twinkle little star I know when you're what you are high up above the world so I like diamond in the sky

Transcription is far from perfect, but you get to see an example here of chunking the stream as we go and how it corrects with context.

Note: nursery rhymes / poetry probably really push the context fixing in terrible directions, but it's the thing that I can repeat over and over again as a parent of a young child.

watson-streaming-localfile-stt's People

Contributors

sdague avatar soominjung avatar afrittoli avatar

Stargazers

 avatar  avatar  avatar Yunseong Hwang avatar Jabrils avatar Muhammad Naqvi avatar Álvaro García León avatar Taehoon Kim avatar Avneet avatar Sooyoung Moon avatar

Forkers

mercileesb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.