mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-11 13:59:23 -04:00
Merge pull request #1580 from picklesrus/speech-language
Send the language code of the project viewer to the server
This commit is contained in:
commit
b063226fd7
1 changed files with 11 additions and 1 deletions
|
@ -199,6 +199,14 @@ class Scratch3Speech2TextBlocks {
|
|||
return words;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the viewer's language code.
|
||||
* @return {string} the language code.
|
||||
*/
|
||||
_getViewerLanguageCode () {
|
||||
return formatMessage.setup().locale || navigator.language || navigator.userLanguage || 'en-US';
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all things related to listening. Called on Red Stop sign button.
|
||||
* - suspends audio processing
|
||||
|
@ -547,10 +555,12 @@ class Scratch3Speech2TextBlocks {
|
|||
// it, start streaming the audio bytes to the server and listening for
|
||||
// transcriptions.
|
||||
this._socket.addEventListener('message', this._socketMessageCallback, {once: true});
|
||||
const langCode = this._getViewerLanguageCode();
|
||||
this._socket.send(JSON.stringify(
|
||||
{
|
||||
sampleRate: this._context.sampleRate,
|
||||
phrases: this._phraseList
|
||||
phrases: this._phraseList,
|
||||
locale: langCode
|
||||
}
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue