我正在尝试将音频文件发送到 dialogflow API 以进行意图检测。我已经有一个代理工作得很好,但只有文本。我正在尝试添加音频功能,但没有运气。
我正在使用此页面中提供的示例(Java):
https://cloud.google.com/dialogflow-enterprise/docs/detect-intent-audio#detect-intent-text-java
这是我的代码:
public DetectIntentResponse detectIntentAudio(String projectId, byte [] bytes, String sessionId,
String languageCode)
throws Exception {
// Set the session name using the sessionId (UUID) and projectID (my-project-id)
SessionName session = SessionName.of(projectId, sessionId);
System.out.println("Session Path: " + session.toString());
// Note: hard coding audioEncoding and sampleRateHertz for simplicity.
// Audio encoding of the audio content sent in the query request.
AudioEncoding audioEncoding = AudioEncoding.AUDIO_ENCODING_LINEAR_16;
int sampleRateHertz = 16000;
// Instructs the speech recognizer how to process …Run Code Online (Sandbox Code Playgroud)