test: add qwen tts adapter and voice preference reproducers
This commit is contained in:
+40
@@ -60,4 +60,44 @@ class AihrSpeechServiceTest {
|
||||
assertThrows(IllegalArgumentException.class, () -> AihrSpeechService.buildRequestBody(
|
||||
mapper, runtime, "测试", null, invalid));
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildsDashScopeQwenTtsRequestAndNormalizesWorkspaceEndpoint() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
SpeechModel runtime = new SpeechModel(
|
||||
"dashscope",
|
||||
"qwen-audio-3.0-tts-flash",
|
||||
"",
|
||||
""
|
||||
);
|
||||
|
||||
var body = AihrSpeechService.buildDashScopeRequestBody(
|
||||
mapper, runtime, "请先确认业主的诉求。",
|
||||
new VoiceProfile("mentor", null, 0.88, "warm", "mandarin"));
|
||||
|
||||
assertEquals("qwen-audio-3.0-tts-flash", body.path("model").asText());
|
||||
assertEquals("请先确认业主的诉求。", body.path("input").path("text").asText());
|
||||
assertEquals("longanhuan_v3.6", body.path("input").path("voice").asText());
|
||||
assertEquals("mp3", body.path("input").path("format").asText());
|
||||
assertEquals(24000, body.path("input").path("sample_rate").asInt());
|
||||
assertEquals(0.88, body.path("input").path("rate").asDouble());
|
||||
assertEquals(
|
||||
"https://ws-example.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/tts/SpeechSynthesizer",
|
||||
AihrSpeechService.dashScopeSynthesisUri("https://ws-example.cn-beijing.maas.aliyuncs.com/compatible-mode/v1").toString()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractsDashScopeAudioUrlOnlyWhenPresent() throws Exception {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String response = """
|
||||
{"output":{"audio":{"url":"http://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/audio.mp3?sig=ok"}}}
|
||||
""";
|
||||
|
||||
assertEquals(
|
||||
"http://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/audio.mp3?sig=ok",
|
||||
AihrSpeechService.dashScopeAudioUrl(mapper, response).orElseThrow()
|
||||
);
|
||||
assertTrue(AihrSpeechService.dashScopeAudioUrl(mapper, "{\"output\":{}}").isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user