jasperproject / jasper-client

Client code for Jasper voice computing platform
MIT License
4.52k stars 1.01k forks source link

Multiple crashed with STT engines #612

Open edouardo17 opened 7 years ago

edouardo17 commented 7 years ago

Hi everybody! I'm new on Github and hopeful to find some help to solve my problems! I've been trying to install Jasper on my Raspberry Pi 3 running on Rasbian, and having overcome many issues by looking into the forums, there is one that can't seem to be solve with my knowledge...

My problem is the following: After trying three different STT engines, I can't find one that makes Jasper happy... 1- Google STT:

For the Google STT, here is how my profile.yml looked like:

carrier: ' '
first_name: Edouard
gmail_address: **************
gmail_password: ***********
last_name: Fourmaux
wmo_id: 07630
phone_number: '7********9'
prefers_email: false
timezone: FR
stt_engine: google
keys:
    GOOGLE_SPEECH: AIza*************************200
tts_engine: google-tts

And when running jasper.py, I get the following error everytime the microphone hears something: CRITICAL:client.stt:API key missing, transcription request aborted. I don't know why the API key is not read or even detected... I have tried many different configuration to make sure it wasn't something wrong with the space: one or two or more spaces before the GOOGLE-SPEECH, I have tried with and without quotes etc.

2- AT&T STT engine With this one, I run jasper.py and get the following Python error:

ERROR:root:Error occured!
Traceback (most recent call last):
  File "jasper.py", line 146, in <module>
    app = Jasper()
  File "jasper.py", line 109, in __init__
    stt_passive_engine_class.get_passive_instance(),
  File "/home/pi/jasper/client/stt.py", line 48, in get_passive_instance
    return cls.get_instance('keyword', phrases)
  File "/home/pi/jasper/client/stt.py", line 42, in get_instance
    instance = cls(**config)
TypeError: __init__() takes exactly 3 arguments (1 given)

3- Witai SST With this last engine, I almost get the same message when running jasper.py, only the number of argument that the init() takes is different...

ERROR:root:Error occured!
Traceback (most recent call last):
  File "jasper.py", line 146, in <module>
    app = Jasper()
  File "jasper.py", line 109, in __init__
    stt_passive_engine_class.get_passive_instance(),
  File "/home/pi/jasper/client/stt.py", line 48, in get_passive_instance
    return cls.get_instance('keyword', phrases)
  File "/home/pi/jasper/client/stt.py", line 42, in get_instance
    instance = cls(**config)
TypeError: __init__() takes exactly 2 arguments (1 given)

Could someone point me in the right direction? I send you many thanks in advance!

Edouard

G10DRAS commented 7 years ago
  1. Remove TAB from
    keys:
    GOOGLE_SPEECH: AIza*************************200

    and simply put 2 SPACES

    keys:
    GOOGLE_SPEECH: AIza*************************200
  2. Do not bother about ATT-STT, it is already shutdown.
  3. for Wit-ai STT get your access tocken and insert following config in profile.yml config
    stt_engine: witai
    witai-stt:
    access_token:  <ACCESS TOKEN>
edouardo17 commented 7 years ago

Thanks G10DRAS for your reply!

1- unfortunately, as I mentionned in my previous message, I tried all sorts of syntax for the Google SST API key. It includes adding spaces (one, two or more) instead of tab (and I think I didn't even tried tab because it returned a Python Error about an unexpected "\t" or something), or adding quotes like " or ' around the key, or writing the key on a new line among other things I tried. The interesting thing is that I get the exact same error if I don't write anything at all on this line... for these previous reasons, I suspect it doesn't come from the syntax but from something else...

2- I take good note of that

3- Same problem than with Google STT, it is exactly how my profile.yml looked like when I tried Wit-ai, but that gave me the error I mentioned in my first message.

Thanks for your help

G10DRAS commented 7 years ago

how you are running jasper ? sudo ?

edouardo17 commented 7 years ago

Yes i'm running Jasper by typing the following line: sudo python jasper.py

G10DRAS commented 7 years ago

thats why the issue. run it as normal user python jasper.py

edouardo17 commented 7 years ago

Hi G10DRAS! Now you were right! Now it jumps to another error message, which is the following...

CRITICAL:client.stt:Request failed with http status 403
WARNING:client.stt:Status 403 is probably caused by an invalid Google API key.

As you may guess, i checked and rechecked a thousand times my API key and it is correct. Do I need to put quotes around the key?

edouardo17 commented 7 years ago

Ooooookay!!! It's working now! I have let Google down and I am now using Wit-ai! I have just a quick couple of questions while I have someone that seems to know Jasper quite well! 1- The AI keeps understanding 'JUST FOR' instead of 'JASPER'... May be because I am French or something... I am quite comfortable with Python programming, so do you happen to know where I could find the code that tells what word should trigger the high beep, I may try to add 'JUST FOR' to the list of the triggering word so it works better ;) 2- I found the time period between the high beep and the low beep is very short... Is the low beep triggered when the mic hears something or is there a time period during which the AI waits for the user to speak? Do you know any trick to increase that time ?

Thank you so much in anycase, you made my stuff worked, and I am so grateful for it! :D

G10DRAS commented 7 years ago

Well there is no particular reason why such issue occurs. (OS, STT, Mic, Alsa config... blah blah).

  1. You can change Keyword in jasper.py line 120.
  2. see /client/mic.py there are various parameters THRESHOLD , LISTEN_TIME, THRESHOLD_MULTIPLIER, MAGIC NUMBER. Try adjusting them for your environment.

One user solve it by doing following.

Yes, i will solve it throw modify mic.py and introduce an different loop timing in active listener and also remove the break (i have to consider it)
i would to add:
for i in range (0,100):
time.sleep(0.5)
something like this
Mvpchris commented 7 years ago

@G10DRAS Do you have any suggestions for this error below? Ive tried to install sphinx as my STT. After some digging I realized the instructions on the Jasper website is wrong for installing sphinx. I found a way around but Im getting this error below preventing jasper from running. I put two spaces instead of the tab like you instructed the person above me but I do not understand this mistake.

RuntimeError: hmm_dir '/usr/local/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k' does not exist! Please make sure that you have set the correct hmm_dir in your profile.

G10DRAS commented 7 years ago

yaml config don't like TAB.

The below error explain itself:

RuntimeError: hmm_dir '/usr/local/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k' does not exist! Please make sure that you have set the correct hmm_dir in your profile.

Use following config for sphinx stt and replace path of fst model and hmm_dir with your installation.

stt_engine: sphinx
pocketsphinx:
  fst_model: '/home/pi/phonetisaurus/g014b2b.fst'
  hmm_dir: '/usr/local/share/pocketsphinx/model/en-us/en-us'
Mvpchris commented 7 years ago

@G10DRAS How do I find my hmm_dir so I can paste the correct path in my profile? I still get the same error when I replaced my profile with what you suggested

This is the code I used to install pocketsphinx so its in my raspberrypi somewhere: sudo apt-get install pocketsphinx-hmm-en-hub4wsj

This was the site I used when I first ran into problems installing pocket sphinx: http://chrismeiercs.com/blog/2016/02/27/installing-jasper-on-raspberry-pi-b-plus/

G10DRAS commented 7 years ago

Search for dir under /usr/local/share/pocketsphinx/model which contains below files 'mdef', 'feat.params', 'means', 'noisedict', 'transition_matrices', 'variances' thats hmm_dir. or download the latest model from CMU Sphinx Site

Mvpchris commented 7 years ago

@G10DRAS ok I downloaded the model and corrected the path to my hmm_dir. Jasper is now able to work but it doesn't understand what I'm saying. After failing I tried switching to google's STT but of course it is very limited so I figured it would be better to stick it out with Pocketsphinx. I understand its possible to train sphinx to your words/voice. I tried to follow the steps in the link below but of course more errors occurred. Do you recommend any methods or videos or tutorials or anything I should try to get sphinx to understand me? (By the way I thank you so much for getting me this far! Everytime I take a step for with Jasper some error just brings me back smh. Developers for Jasper should pay you for fixing so much of their terrible code and instructions)

Attempt at training sphinx in Jasper: https://www.youtube.com/watch?v=VLhj_WYxo7g

G10DRAS commented 7 years ago

In Jasper Pocketsphinx operates on limited vocab, so you can't expect it will transcribe full sentences, hence there is no point to train sphinx with your voice.

Mvpchris commented 7 years ago

@G10DRAS Ok. So is there a way to at least see what words Sphinx recognizes? If so I'll just adjust my modules in jasper to those words sphinx recognize. For example if I say "Light" and sphinx recognizes it as "Now". I could change my module keyword to "Now" and my light module will activate.

You think I could trick jasper in someway like this or do I just need to stick with another STT

G10DRAS commented 7 years ago

If "Light" transcribe as "Now" then its wrong. "Light" is "Light", "Now" is "Now" not even "Wow". Jasper automatically generates dictionary and lm for Pocketsphinx, hence no need to adjust anything in module. It might possible that something is wrong with Pocketsphinx installation itself. Try compiling pocketsphinx (with sphinxbase) from source and install it. (see jasper doc for instruction, version and links) Test the installation with pocketsphinx_continuous if that work well then Jasper will also work well with Pocketsphinx. Test your USB Mic with arecordand check if there is no problem in recording your voice.

Another STT ? You dont have much choices left unless you are ready to pay for online STT service.