Python Pocketsphinx:无法从.wav文件中识别关键字

问题描述 投票:1回答:1

我正试图从我的录音中检测出关键字temperature,但只说出相温度(没有其他词出现)。最初,我使用关键字hello,但效果很好,但是每当尝试使用其他任何单词时,它都不会。我当前的代码如下:

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)

我的keyphrase.list文件的内容是:

temperature /1e-1/

它目前已启动并运行,但未检测到任何东西。

python speech-recognition pocketsphinx
1个回答
0
投票

尝试不同的阈值,例如1e-10、1e-20、1e-30、1e-40。

© www.soinside.com 2019 - 2024. All rights reserved.