I don't find how to send a local file using the Google STT in curl command line. As followed in their tuto, here my request.json :
{
"config": {
"encoding":"FLAC",
"sample_rate": 16000,
"language_code": "fr-FR"
},
"audio": {
"uri":"audio-file.flac"
}
}
my command line is:
curl -s -X POST -H "Content-Type: application/json" --data-binary @request.json "https://speech.googleapis.com/v1beta1/speech:syncrecognize?key=MY_API_KEY"
But I receive the error result:
{
"error": {
"code": 400,
"message": "RecognitionAudio not set.",
"status": "INVALID_ARGUMENT"
}
}
How can I write the request.json to send a local audio file ?? Thanks for help :)
You need to use the base64 in the content section of the request.json file. It should look something like this except with a lot more base64 data:
{
'config': {
"encoding":"FLAC",
"sample_rate": 16000,
"language_code": "fr-FR"
},
'audio': {
'content':'UklGRuRDFQBXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YcBDFQAIAAgACAAIAAgA
CAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgA
CAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgA
CAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD4/wgACAD4//j/+P8IAPj/+P8IAAgA
+P8IAAgACAAIAAgA+
'
}
}