fix(voce): riproduce la sintesi vocale sul display invece che sul controller
Il controller invia un comando 'speak' via WebSocket. Il server inoltra il messaggio solo ai client display, che eseguono speechSynthesis con preferenza per voce italiana.
This commit is contained in:
@@ -481,21 +481,29 @@ export default {
|
||||
},
|
||||
|
||||
speak() {
|
||||
const msg = new SpeechSynthesisUtterance()
|
||||
let text = ''
|
||||
if (this.state.sp.punt.home + this.state.sp.punt.guest === 0) {
|
||||
msg.text = "zero a zero"
|
||||
text = "zero a zero"
|
||||
} else if (this.state.sp.punt.home === this.state.sp.punt.guest) {
|
||||
msg.text = this.state.sp.punt.home + " pari"
|
||||
text = this.state.sp.punt.home + " pari"
|
||||
} else {
|
||||
if (this.state.sp.servHome) {
|
||||
msg.text = this.state.sp.punt.home + " a " + this.state.sp.punt.guest
|
||||
text = this.state.sp.punt.home + " a " + this.state.sp.punt.guest
|
||||
} else {
|
||||
msg.text = this.state.sp.punt.guest + " a " + this.state.sp.punt.home
|
||||
text = this.state.sp.punt.guest + " a " + this.state.sp.punt.home
|
||||
}
|
||||
}
|
||||
const voices = window.speechSynthesis.getVoices()
|
||||
msg.voice = voices.find(v => v.name === 'Google italiano')
|
||||
window.speechSynthesis.speak(msg)
|
||||
if (!this.wsConnected || !this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
||||
this.showErrorFeedback('Non connesso al server')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
this.ws.send(JSON.stringify({ type: 'speak', text }))
|
||||
} catch (err) {
|
||||
console.error('[Controller] Failed to send speak command:', err)
|
||||
this.showErrorFeedback('Errore invio comando voce')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user