Menu

Python: Keyword not being recognised from a .wav file

Help
Jack Johns
2020-06-01
2020-06-01
  • Jack Johns

    Jack Johns - 2020-06-01

    I'm trying to detect the keyword temperature from a recording of me only saying the phrase temperature (there are no other words present). Originally I used the keyword hello and it worked fine but whenever I try with any other word it does not. My current code is as follows:

    import pocketsphinx as ps
    import requests
    import json
    import sys, os
    
    model_path = ps.get_model_path()
    data_path = ps.get_data_path()
    
    # Call to API
    def get_temperature():
        headers = {
            'accept': 'application/json',
            'x-api-key': 'REMOVED'
        }
    
        response = requests.get(url=TEMPERATURE_URL, headers=headers)
        print("Response Code: ", response)
    
        temperature_data = response.json()
        print(temperature_data)
        temp = temperature_data[0]["value"]
        return temp
    
    print("start")
    while True:
        speech = ps.AudioFile(lm=False, kws='keyphrase.list', kws_threshold=1e-1)
        for phrase in speech:
            print("--------------------------------------------------------------")
            print(phrase.segments(detailed=True))
            print(phrase)
            if phrase.__eq__('temperature '):
                print("if equal")
                temperature = get_temperature()
                print("Temperature: ", temperature)
    

    The contents of my keyphrase.list file is:

    temperature /1e-1/
    

    It currently starts and runs but doesn't detect anything. Any help would be much appreciated.

     
    • Nickolay V. Shmyrev

      Try threshold 1e-20, 30, 40

      I replied you on stack overflow already.

       
      • Jack Johns

        Jack Johns - 2020-06-01

        Hi, thanks for the reply. I've just tried this and it didn't change anything. Have you got any other ideas?

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.