项目作者: inforkgodara

项目描述 :
A few lines of code which convert speech to text.
高级语言: Python
项目地址: git://github.com/inforkgodara/python-speech-to-text.git
创建时间: 2020-08-23T12:55:20Z
项目社区:https://github.com/inforkgodara/python-speech-to-text

开源协议:

下载


Python Speech To Text

A few lines of code written in python using libraries (SpeechRecognition, PyAudio) that convert speech to text.

Prerequisites

In order to run the python script, your system must have the following programs/packages installed.

  • Python 3.6.7
  • SpeechRecognition 3.8.1 (Internet required to convert speech to text while execution)
  • PyAudio

Approach

  • script.py execute in terminal.
  • After a printed start in the terminal, you begin to speak in English and end once your sentence is completed.
  • It will take a few minutes to convert speech to text and print on your terminal.

Code

  1. # Program to convert speech to text
  2. # Author @inforkgodara
  3. import speech_recognition as sr
  4. r = sr.Recognizer()
  5. mic = sr.Microphone()
  6. print('start')
  7. with mic as source:
  8. audio = r.listen(source)
  9. print('end')
  10. print(r.recognize_google(audio))