forked from Blendman974/faceclaw
Add Soniox as an API speech-to-text option
This commit is contained in:
1 parent
852626e950
commit
ba81e46624
9 files changed
+218
-14
No files matched your search
+11
-5
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* Shared shape for the cloud speech-to-text providers (ElevenLabs, Whisper).
|
||||
* Shared shape for the cloud speech-to-text providers (ElevenLabs, Whisper,
|
||||
* Soniox).
|
||||
* The voice bridge holds one of these while a cloud provider owns the
|
||||
* transcript; the Java controller then only decodes LC3 to PCM and hands it
|
||||
* over via acceptPcm.
|
||||
@@ -33,13 +34,18 @@ export const CLOUD_STT_SAMPLE_RATE = 16000;
|
||||
|
||||
declare const android: any;
|
||||
|
||||
/** Base64 for audio payloads, via the Android SDK (no JS base64 in NS core). */
|
||||
export function encodeBase64(bytes: Uint8Array): string {
|
||||
if (!global.isAndroid) return "";
|
||||
/** Copy a Uint8Array into a Java byte[] (for binary WebSocket frames etc.). */
|
||||
export function toJavaBytes(bytes: Uint8Array): any {
|
||||
const javaBytes = Array.create("byte", bytes.length);
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
const value = bytes[i]!;
|
||||
javaBytes[i] = value > 127 ? value - 256 : value;
|
||||
}
|
||||
return String(android.util.Base64.encodeToString(javaBytes, android.util.Base64.NO_WRAP));
|
||||
return javaBytes;
|
||||
}
|
||||
|
||||
/** Base64 for audio payloads, via the Android SDK (no JS base64 in NS core). */
|
||||
export function encodeBase64(bytes: Uint8Array): string {
|
||||
if (!global.isAndroid) return "";
|
||||
return String(android.util.Base64.encodeToString(toJavaBytes(bytes), android.util.Base64.NO_WRAP));
|
||||
}
|
||||
Reference in new issue
Block a user