Тело ответа
Я пытаюсь реализовать API преобразования речи в текст Google Cloud в Unity.
В URL-адресе используется "https://speech.googleapis.com/v1/speech ... "+{API_KEY}
Подробный код приведен ниже.
Ответ request.downloadHandler.text содержит только requestId и totalBilledTime.
Есть ли какое-нибудь решение?
Я хочу иметь возможность получать правильные данные ответа.
Обычное тело ответа
{
results,
totalBilledTime,
speechAdaptationInf,
requestId,
var jsonRequest = new SpeechToTextRequest
{
config = new AudioConfig { encoding = "LINEAR16", sampleRateHertz = 16000, languageCode = "ja-JP"},
audio = new SpeechToTextInput { content = base64Audio}
};
var request = new UnityWebRequest(url, "POST")
{
uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(JsonUtility.ToJson(jsonRequest))),
downloadHandler = new DownloadHandlerBuffer()
};
request.SetRequestHeader("Content-Type", "application/json");
await request.SendWebRequest().ToUniTask();
if (request.result == UnityWebRequest.Result.Success)
{
var response = request.downloadHandler.text;
}
else
{
throw new Exception($"Error: {request.error}");
}
[Serializable]
private class SpeechToTextRequest
{
public AudioConfig config;
public SpeechToTextInput audio;
}
[Serializable]
private class AudioConfig
{
public string encoding = "LINEAR16";
public int sampleRateHertz = 16000;
public string languageCode = "ja-JP";
}
[Serializable]
private class SpeechToTextInput
{
public string content;
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... billedtime
Google Cloud Speech-to-Text API возвращает только requestId и totalBilledTime. ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Google Cloud Speech-to-Text API возвращает только requestId и totalBilledTime.
Anonymous » » в форуме C# - 0 Ответы
- 15 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Google Cloud Speech-to-Text API возвращает только requestId и totalBilledTime.
Anonymous » » в форуме C# - 0 Ответы
- 12 Просмотры
-
Последнее сообщение Anonymous
-