Python Forum
Offline audio to text (Speech Recognition)
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Offline audio to text (Speech Recognition)
#6
(Dec-04-2017, 11:04 PM)snippsat Wrote: You can look at Linux Python 3 environment.

Is pip a reflection of python dependancies ? I ran the following

pip list
Quote:DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the "list" section) to disable this warning.
netifaces (0.10.4)
pip (9.0.1)
PyAudio (0.2.11)
pygobject (3.20.0)
setuptools (20.7.0)
SpeechRecognition (3.7.1)
vboxapi (1.0)
wheel (0.29.0)
youtube-dl (2017.11.15)

pip3 list
Quote:DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the "list" section) to disable this warning.
apt-xapian-index (0.47)
apturl (0.5.2)
chardet (2.3.0)
command-not-found (0.3)
defer (1.0.6)
language-selector (0.1)
pexpect (4.0.1)
Pillow (3.1.2)
pip (9.0.1)
pocketsphinx (0.1.3)
ptyprocess (0.5)
PyAudio (0.2.8)
pycups (1.9.73)
pycurl (7.43.0)
pygobject (3.20.0)
python-apt (1.1.0b1)
python-debian (0.1.27)
python-systemd (231)
reportlab (3.3.0)
requests (2.9.1)
setuptools (20.7.0)
six (1.10.0)
SpeechRecognition (3.7.1)
ssh-import-id (5.5)
ubuntu-drivers-common (0.0.0)
ufw (0.35)
unattended-upgrades (0.1)
urllib3 (1.13.1)
wheel (0.29.0)
xkit (0.0.0)

pip and pip3 are both showing as version 9.0.1

The small script that I'm using is based on the example script from https://github.com/Uberi/speech_recognit...nscribe.py

#!/usr/bin/env python3

import speech_recognition as sr

# obtain path to "english.wav" in the same folder as this script
from os import path
AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "english.wav")
# AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "french.aiff")
# AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "chinese.flac")

# use the audio file as the audio source
r = sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
    audio = r.record(source)  # read the entire audio file

# recognize speech using Sphinx
try:
    print("Sphinx thinks you said " + r.recognize_sphinx(audio))
except sr.UnknownValueError:
    print("Sphinx could not understand audio")
except sr.RequestError as e:
    print("Sphinx error; {0}".format(e))
and most of it is inaccurate, some words are okay though. I was advised to try and break things up into sentences. This can be done by repeatedly calling r.listen instead of r.record. So, 'r.record' in the above code reads the entire file and then does the sphinx processing. I need to change the script to do the r.listen.

Have done a bit of searching and realise it is dome within a 'while' loop, but just can't find the exact code. Psuedo code would be something like ..

Quote:Set the audio file path
use the audio file as the source
Read a part of the file
if EOF end
else
Call 'r.listen'
Call sphinx functions
End
Reply


Messages In This Thread
RE: Offline audio to text (Speech Recognition) - by jehoshua - Dec-06-2017, 12:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  installing anaconda packages offline HulkHogansArmsArePythons 4 7,394 Feb-18-2020, 08:23 PM
Last Post: jefsummers
  CNN Speech Classification Mitchie87 0 1,621 Dec-06-2019, 06:17 PM
Last Post: Mitchie87
  Tensorflow offline build from source on CentOS 7 riotto 3 4,038 Mar-21-2019, 07:16 PM
Last Post: riotto
  [Plot a stacked bar graph using plotly offline mode] niks250891 1 5,212 Apr-22-2018, 02:11 PM
Last Post: niks250891
  AttributeError: module 'plotly' has no attribute 'offline' charlesczc 8 17,138 Jan-21-2018, 08:34 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020