gpt4 book ai didi

android - Google Speech 的空白回复

转载 作者:太空狗 更新时间:2023-10-29 13:50:25 25 4
gpt4 key购买 nike

<分区>

I am using Google Speech REST API to convert speech to text, I am getting blank response. Here is my json which I was passing in Http Post Request:-

这是我获取 JSON 的代码:

File file = new File(mOutputFile.getAbsolutePath());
byte[] bytes = new byte[0];
try {
bytes = loadFile(file);
} catch (IOException e) {
e.printStackTrace();
}
byte[] encoded = Base64.encodeBase64(bytes);
String encodedString = new String(encoded);

JSONObject config = new JSONObject();
config.put("encoding", "FLAC");
config.put("sampleRateHertz", 16000);
config.put("languageCode", "en-US");
config.put("enableWordTimeOffsets", false);
JSONObject audio = new JSONObject();
audio.put("content", "" + encodedString);
JSONObject jsonObject = new JSONObject();
jsonObject.put("config", config);
jsonObject.put("audio", audio);
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost("https://speech.googleapis.com/v1/speech:recognize?key=GOOGLE_API_KEY");
post.setHeader("content-type", "application/json; charset=UTF-8");
StringEntity entity = new StringEntity(jsonObject.toString());
post.setEntity(entity);
HttpResponse resp = httpClient.execute(post);
s = EntityUtils.toString(resp.getEntity());
Log.e("ExecuteTask Response", "--------------" + s);
} catch (Exception e) {
e.printStackTrace();
}

} catch (Exception exception) {
exception.printStackTrace();
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com