Started google cloud tests

This commit is contained in:
Pax1601
2024-11-28 20:08:43 +01:00
parent dd641fc2aa
commit 42e62be0f5
6 changed files with 52 additions and 46 deletions

View File

@@ -158,8 +158,6 @@ export class AudioManager {
this.#devices = devices;
AudioManagerDevicesChangedEvent.dispatch(devices);
});
this.#startSpeechRecognition();
}
stop() {
@@ -330,30 +328,4 @@ export class AudioManager {
if (this.#socket?.readyState == 1) this.#socket?.send(new Uint8Array([AudioMessageType.settings, ...Buffer.from(JSON.stringify(message), "utf-8")]));
}
#startSpeechRecognition() {
const grammar =
"#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
//@ts-ignore
const recognition = new window.webkitSpeechRecognition();
//@ts-ignore
const speechRecognitionList = new window.webkitSpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
recognition.continuous = true;
recognition.lang = "en-US";
recognition.interimResults = true;
//recognition.maxAlternatives = 1;
const diagnostic = document.querySelector(".output");
const bg = document.querySelector("html");
recognition.start();
recognition.onresult = (event) => {
const color = event.results[0][0].transcript;
diagnostic.textContent = `Result received: ${color}`;
bg.style.backgroundColor = color;
};
}
}

View File

@@ -26,7 +26,7 @@ export class TextToSpeechSource extends AudioSource {
body: JSON.stringify({ text }), // Send the data in JSON format
};
fetch(getApp().getExpressAddress() + `/api/texttospeech/generate`, requestOptions)
fetch(getApp().getExpressAddress() + `/api/speech/generate`, requestOptions)
.then((response) => {
if (response.status === 200) {
console.log(`Text to speech generate correctly`);