Uberi / speech_recognition

Speech recognition module for Python, supporting several engines and APIs, online and offline.
https://pypi.python.org/pypi/SpeechRecognition/
BSD 3-Clause "New" or "Revised" License
8.43k stars 2.4k forks source link

How to add new words to pocketsphinx #379

Closed tvikneshwar closed 6 years ago

tvikneshwar commented 6 years ago

Steps to reproduce

  1. (How do you make the issue happen? Does it happen every time you try it?)
  2. (Make sure to go into as much detail as needed to reproduce the issue. Posting your code here can help us resolve the problem much faster!)
  3. (If there are any files, like audio recordings, don't forget to include them.)

Expected behaviour

(What did you expect to happen?)

Actual behaviour

(What happened instead? How is it different from what you expected?)

(If the library threw an exception, paste the full stack trace here)

System information

(Delete all the statements that don't apply.)

My system is . (For example, "Ubuntu 16.04 LTS x64", "Windows 10 x64", or "macOS Sierra".)

My Python version is . (You can check this by running python -V.)

My Pip version is . (You can check this by running pip -V.)

My SpeechRecognition library version is . (You can check this by running python -c "import speech_recognition as sr;print(sr.__version__)".)

My PyAudio library version is / I don't have PyAudio installed. (You can check this by running python -c "import pyaudio as p;print(p.__version__)".)

My microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_microphone_names())".)

My working microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_working_microphones())".)

I installed PocketSphinx from . (For example, from the Debian repositories, from Homebrew, or from the source code.)

palikar commented 6 years ago

I don't quite understand the question. You may want to elaborate a bit more.

With that being said, the method recognize_sphinx from the Recogniser class takes a positional argument keyword_entries which is a list of tuples of a string and a float between 0 and 1. The words in the list is what sphinx will look for while processing the audio. Reference the documentation for more details.

I hope that answers your question.

tvikneshwar commented 6 years ago

I am working on HFM(Hands Free Module ) based Car Infotainment System and the objective of this project is to make hands free call through the connected phone by pronouncing contact name, eg call Hari Lal .My speech recognition engine can recognise the words Call, Dial, Redial easily , because those words are already in the dictionary (generic words).How to create dictionary for names those are not in dictionary.

palikar commented 6 years ago

Hi @tvikneshwar.

Ok, now I know what you mean. Sadly, I cannot really help you nor can this library. From what I understand, you want to add certain "custom" words to the language model of Sphinx itself. This is not a trivial task. I suppose you'll have to build a completely separate model if you want to achieve this. Online I've found this tutorial on the official Sphinx page. You should really look into Sphinx if you want something custom behavior on the actual speech recognizer . The library here just brings several APIs together and doesn't extend the functionality of Sphinx (or any other API). After you've build your model, you can follow the instructions in the documentation on adding a language model to the Sphinx API in the library. This is not that hard.