Skip to content

jybaek/gcp_speech_api

Repository files navigation

Python 3.x

Google Cloud Platform (GCP) - speech api

This is an example using Google's speech to text api. A little more details can be found on the blog below.

http://jybaek.tistory.com/671

GCP Prerequisite

  • Please install gcloud sdk first.
  • Perform authentication and resolve associated dependencies.

Authentication

$ gcloud auth application-default login

Install Dependencies

$ pip install -r requirements.txt

Usage

Audio file recognition

To convert a file to text in its entirety, proceed as follows.

$ python speech.py
Transcript: 안녕 하세요 좋은 아침입니다

The default is to specify test.raw via the audio-path option. Take a look at the options through help as below.

$ python speech.py --help
usage: speech.py [-h] [--audio-path AUDIO_PATH]
                 [--language-code LANGUAGE_CODE]

speech to text

optional arguments:
  -h, --help            show this help message and exit
  --audio-path AUDIO_PATH
                        Audio file to convert to text.
  --language-code LANGUAGE_CODE
                        Language code. ( ko-KR, en-US, etc.. )

Here is an example of converting a file to streaming. The options are the same as for speech.py.

$ python speech_streaming.py
====================
transcript: 안녕 하세요 좋은 아침입니다
confidence: 0.5344622135162354

Real-time speech recognition

You need to install pypaudio, please refer to the link below to install it first.

https://stackoverflow.com/a/33821084/4599185

After the installation is completed, you can do the following. Speech recognition is pending, so deliver voice over the microphone.

$ python transcribe_streaming_mic.py

Most of the sample code that is registered with googlecloudplatform is used.

About

Google Cloud Platform (GCP) Speech API sample

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages