rhasspy icon indicating copy to clipboard operation
rhasspy copied to clipboard

Error: not a wave file in API call

Open TheMasterRoot opened this issue 4 years ago • 0 comments

im trying to use speech-to-intent api but im getting this error:

root@raspbx:/var/lib/asterisk/agi-bin# ./speech_cmd.py have-a-good-weekend.wav

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3240  100    22  100  3218    186  27271 --:--:-- --:--:-- --:--:-- 27457
Error: not a WAVE file

i have the following code:

#!/usr/bin/python3
import sys
sys.dont_write_bytecode = True
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument('fileName', type=str, help='Nome do audio a ser identificado')
args = vars(parser.parse_args())

fileName = args['fileName']
if fileName:
	#print(fileName)
	#sys.exit(0)
	ret = os.popen("sox /var/spool/stt/"+fileName+" -L -e signed-integer -c 1 -r 16000 -b 16 /var/spool/stt/sox_"+fileName+"").read()
	print(ret)
	#content = os.popen("cat /var/spool/stt/"+fileName).read()
	output = os.popen("curl -X POST 'http://192.168.240.215:12101/api/speech-to-intent' -H 'accept: application/json' -H 'Content-Type: audio/wav' -d '@/var/spool/stt/sox_"+fileName+"'").read()
	print(output)

i dont know what is the problem. becouse this same audio file that is generated by sox works in audio upload in rhasspy panel and rhasspi api test

in command line with other file in getting it:

root@raspbx:/var/spool/stt# curl -X POST "http://192.168.240.215:12101/api/speech-to-intent?nohass=true&outputFormat=rhasspy" -H "accept: application/json" -H "Content-Type: audio/wav" -d "./@teste.wav"
Error: file does not start with RIFF id

TheMasterRoot avatar Aug 11 '20 16:08 TheMasterRoot