feat(clients): google cloud voice: generic client, TTS, STT, Gemini audio, live voice page
src/google: GoogleClient over molo::clients (key in x-goog-api-key, never in
URLs), Service base, TextToSpeech, SpeechToText, Generative (replies, audio
in, audio out), Recognizer/Synthesizer seams with cloud, gemini and vertex
backends, VoicePipeline with bounded history. Example: /voice live
conversation page, /voice/{say,hear,turn,reset}, /google/status. Keys load
from env, .env.json.local, .env.json. Paid routes are excluded from locust.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#include "google/voice_io.h"
|
||||
|
||||
namespace molo::google {
|
||||
|
||||
const char* audio_encoding_name(AudioEncoding encoding) {
|
||||
switch (encoding) {
|
||||
case AudioEncoding::kMp3: return "MP3";
|
||||
case AudioEncoding::kLinear16: return "LINEAR16";
|
||||
case AudioEncoding::kOggOpus: return "OGG_OPUS";
|
||||
}
|
||||
return "MP3";
|
||||
}
|
||||
|
||||
const char* audio_encoding_mime(AudioEncoding encoding) {
|
||||
switch (encoding) {
|
||||
case AudioEncoding::kMp3: return "audio/mpeg";
|
||||
case AudioEncoding::kLinear16: return "audio/wav";
|
||||
case AudioEncoding::kOggOpus: return "audio/ogg";
|
||||
}
|
||||
return "audio/mpeg";
|
||||
}
|
||||
|
||||
const char* speech_encoding_name(SpeechEncoding encoding) {
|
||||
switch (encoding) {
|
||||
case SpeechEncoding::kWebmOpus: return "WEBM_OPUS";
|
||||
case SpeechEncoding::kOggOpus: return "OGG_OPUS";
|
||||
case SpeechEncoding::kFlac: return "FLAC";
|
||||
case SpeechEncoding::kLinear16: return "LINEAR16";
|
||||
case SpeechEncoding::kMp3: return "MP3";
|
||||
}
|
||||
return "WEBM_OPUS";
|
||||
}
|
||||
|
||||
const char* speech_encoding_mime(SpeechEncoding encoding) {
|
||||
switch (encoding) {
|
||||
case SpeechEncoding::kWebmOpus: return "audio/webm";
|
||||
case SpeechEncoding::kOggOpus: return "audio/ogg";
|
||||
case SpeechEncoding::kFlac: return "audio/flac";
|
||||
case SpeechEncoding::kLinear16: return "audio/wav";
|
||||
case SpeechEncoding::kMp3: return "audio/mpeg";
|
||||
}
|
||||
return "audio/webm";
|
||||
}
|
||||
|
||||
bool speech_encoding_from_mime(const std::string& mime, SpeechEncoding& out) {
|
||||
auto has = [&](const char* s) { return mime.find(s) != std::string::npos; };
|
||||
if (has("webm")) out = SpeechEncoding::kWebmOpus;
|
||||
else if (has("ogg")) out = SpeechEncoding::kOggOpus;
|
||||
else if (has("flac")) out = SpeechEncoding::kFlac;
|
||||
else if (has("wav") || has("l16") || has("pcm")) out = SpeechEncoding::kLinear16;
|
||||
else if (has("mpeg") || has("mp3")) out = SpeechEncoding::kMp3;
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace molo::google
|
||||
Reference in New Issue
Block a user