我尝试使用此 API 并返回此错误:
发生异常。
详细ApiRequestError(DetailedApiRequestError(状态:400,消息:'audio.content'(TYPE_BYTES)的值无效,“/data/user/0/br.com.icourier.mobi/app_flutter/gravacoes/2020-02-的Base64解码失败- 03 14:31:42.328870.m4a"))
我试图说出文件的路径 - “/data/user/0/br.com.icourier.mobi/app_flutter/gravacoes/2020-02-03 14:31:42.328870.m4a”
按照我的代码:
Future<void> audioRecog(dynamic file) {
clientViaServiceAccount(_credentials, _SCOPES).then((http_client) {
var speech = new SpeechApi(http_client);
//var fileAudio = new File(file);
//var newAudio = base64Encode(fileAudio.readAsBytesSync());
//var audio = rootBundle.load(file);
print(file);
File file2 = new File(file); // (1)
print(file2);
Uint8List base64Decode(String file) => base64.decode(file);
print(file);
final _json = {
"audio": {
"content": "$file",
},
"config": {
"enableAutomaticPunctuation": true,
"encoding": "LINEAR16",
"languageCode": "pt-BR",
"model": "default"
}
};
final _recognizeRequest = RecognizeRequest.fromJson(_json);
speech.speech.recognize(_recognizeRequest).then((response) {
for (var result in response.results) {
print(result.toJson());
}
});
});
}
有人能帮我吗?