项目作者: jybaek

项目描述 :
Google Cloud Platform (GCP) Speech API sample
高级语言: Python
项目地址: git://github.com/jybaek/gcp_speech_api.git
创建时间: 2017-08-17T00:10:51Z
项目社区:https://github.com/jybaek/gcp_speech_api

开源协议:

下载


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

  1. $ gcloud auth application-default login

Install Dependencies

  1. $ pip install -r requirements.txt

Usage

Audio file recognition

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

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

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

  1. $ python speech.py --help
  2. usage: speech.py [-h] [--audio-path AUDIO_PATH]
  3. [--language-code LANGUAGE_CODE]
  4. speech to text
  5. optional arguments:
  6. -h, --help show this help message and exit
  7. --audio-path AUDIO_PATH
  8. Audio file to convert to text.
  9. --language-code LANGUAGE_CODE
  10. 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.

  1. $ python speech_streaming.py
  2. ====================
  3. transcript: 안녕 하세요 좋은 아침입니다
  4. 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.

  1. $ python transcribe_streaming_mic.py

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