Table driven REST (509 rows verified against vendor specs by tools/check_spec.py), WebSockets over the src/google/live client, neutral SpeechSynthesizer / SpeechRecognizer seam, /ai/audio demo with dry runs, 110 package tests and 5 route tests. PlayHT has no public API; LeMUR is gone from AssemblyAI's spec. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
35 lines
3.1 KiB
C++
35 lines
3.1 KiB
C++
// Dry runs: anything that generates audio, writes or deletes does not run
|
|
// without "confirm":true, and answers 200 with a preview even without a key.
|
|
#include <cstdlib>
|
|
|
|
#include "support/Assert.hpp"
|
|
|
|
using namespace molo::example::test;
|
|
|
|
int main() {
|
|
for (const char* k : {"ELEVENLABS_API_KEY", "ASSEMBLYAI_API_KEY", "DEEPGRAM_API_KEY", "CARTESIA_API_KEY",
|
|
"SPEECHMATICS_API_KEY", "SPEECHMATICS_MANAGEMENT_TOKEN", "HUME_API_KEY"})
|
|
unsetenv(k);
|
|
Fixture f;
|
|
auto post = [&](const std::string& path, const std::string& body) { return f.client->post(path, body, "application/json"); };
|
|
auto tts = post("/ai/audio/tts", "{\"provider\":\"elevenlabs\",\"text\":\"Hello. This is a test.\",\"voice\":\"v1\"}");
|
|
check(tts.status == 200 && contains(tts.body, "\"dry_run\":true"), "tts without confirm is a dry run");
|
|
check(contains(tts.body, "\"chunks\":1") && contains(tts.body, "confirm"), "dry run reports chunks and how to run it");
|
|
auto stt = post("/ai/audio/stt", "{\"provider\":\"assemblyai\",\"url\":\"https://example.com/a.mp3\"}");
|
|
check(stt.status == 200 && contains(stt.body, "\"dry_run\":true"), "stt without confirm is a dry run");
|
|
auto session = post("/ai/audio/session", "{\"provider\":\"hume\",\"text\":\"hi\"}");
|
|
check(session.status == 200 && contains(session.body, "\"dry_run\":true"), "streaming session without confirm is a dry run");
|
|
auto write = post("/ai/audio/call", "{\"provider\":\"elevenlabs\",\"id\":\"text_to_speech_full\",\"segments\":[\"v1\"],\"body\":{\"text\":\"x\"}}");
|
|
check(write.status == 200 && contains(write.body, "\"dry_run\":true") && contains(write.body, "POST /v1/text-to-speech/v1"), "generation call is a dry run with the path");
|
|
auto del = post("/ai/audio/call", "{\"provider\":\"elevenlabs\",\"id\":\"delete_voice\",\"segments\":[\"v1\"]}");
|
|
check(del.status == 200 && contains(del.body, "\"dry_run\":true") && contains(del.body, "DELETE /v1/voices/v1"), "delete is a dry run");
|
|
auto job = post("/ai/audio/call", "{\"provider\":\"speechmatics\",\"id\":\"jobs_delete\",\"segments\":[\"job1\"],\"query\":{\"force\":true}}");
|
|
check(job.status == 200 && contains(job.body, "force=true"), "speechmatics delete previews its query");
|
|
check(post("/ai/audio/call", "{\"provider\":\"elevenlabs\",\"id\":\"delete_voice\",\"segments\":[\"v1\"],\"confirm\":true}").status == 503, "confirmed delete needs the key");
|
|
check(post("/ai/audio/tts", "{\"provider\":\"elevenlabs\",\"text\":\"x\",\"voice\":\"v1\",\"confirm\":true}").status == 503, "confirmed tts needs the key");
|
|
check(post("/ai/audio/call", "{\"provider\":\"elevenlabs\",\"id\":\"delete_voice\",\"segments\":[\"a/b\"]}").status == 422, "bad id is 422 before the dry run");
|
|
check(post("/ai/audio/call", "{\"provider\":\"elevenlabs\",\"id\":\"text_to_speech_full\",\"segments\":[\"v1\"],\"body\":{\"nope\":1}}").status == 422, "bad body field is 422 before the dry run");
|
|
check(post("/ai/audio/call", "{\"provider\":\"elevenlabs\",\"id\":\"text_to_speech_full\",\"segments\":[\"v1\"]}").status == 422, "missing required body is 422");
|
|
return finish("ai/audio/confirm");
|
|
}
|