From 4d229258530864de338ccdd380e0b77dcdd9269f Mon Sep 17 00:00:00 2001 From: Oscar Neto Date: Mon, 25 Mar 2024 02:16:40 -0300 Subject: [PATCH 1/3] Add multilingual support for speech recognition --- src/components/ArcanaSettingsTab.ts | 212 ++++++++++++++++++++++++++++ src/include/ArcanaAgent.ts | 2 +- src/include/ArcanaSettings.ts | 1 + src/main.ts | 1 + 4 files changed, 215 insertions(+), 1 deletion(-) diff --git a/src/components/ArcanaSettingsTab.ts b/src/components/ArcanaSettingsTab.ts index c275179..90bcfa1 100644 --- a/src/components/ArcanaSettingsTab.ts +++ b/src/components/ArcanaSettingsTab.ts @@ -57,6 +57,218 @@ export default class ArcanaSettingsTab extends PluginSettingTab { }); }); + new Setting(containerEl) + .setName('Input language') + .setDesc('If you use a language other than English to prompt, you need need to set it up otherwise the speech recognition will not work properly. Although, you probably also can use English without the need to change this setting again.') + .addDropdown(dropdown => { + dropdown + .addOption ('en', 'english') + .addOption ('zh', 'chinese') + .addOption ('de', 'german') + .addOption ('es', 'spanish') + .addOption ('ru', 'russian') + .addOption ('ko', 'korean') + .addOption ('fr', 'french') + .addOption ('ja', 'japanese') + .addOption ('pt', 'portuguese') + .addOption ('tr', 'turkish') + .addOption ('pl', 'polish') + .addOption ('ca', 'catalan') + .addOption ('nl', 'dutch') + .addOption ('ar', 'arabic') + .addOption ('sv', 'swedish') + .addOption ('it', 'italian') + .addOption ('id', 'indonesian') + .addOption ('hi', 'hindi') + .addOption ('fi', 'finnish') + .addOption ('vi', 'vietnamese') + .addOption ('he', 'hebrew') + .addOption ('uk', 'ukrainian') + .addOption ('el', 'greek') + .addOption ('ms', 'malay') + .addOption ('cs', 'czech') + .addOption ('ro', 'romanian') + .addOption ('da', 'danish') + .addOption ('hu', 'hungarian') + .addOption ('ta', 'tamil') + .addOption ('no', 'norwegian') + .addOption ('th', 'thai') + .addOption ('ur', 'urdu') + .addOption ('hr', 'croatian') + .addOption ('bg', 'bulgarian') + .addOption ('lt', 'lithuanian') + .addOption ('la', 'latin') + .addOption ('mi', 'maori') + .addOption ('ml', 'malayalam') + .addOption ('cy', 'welsh') + .addOption ('sk', 'slovak') + .addOption ('te', 'telugu') + .addOption ('fa', 'persian') + .addOption ('lv', 'latvian') + .addOption ('bn', 'bengali') + .addOption ('sr', 'serbian') + .addOption ('az', 'azerbaijani') + .addOption ('sl', 'slovenian') + .addOption ('kn', 'kannada') + .addOption ('et', 'estonian') + .addOption ('mk', 'macedonian') + .addOption ('br', 'breton') + .addOption ('eu', 'basque') + .addOption ('is', 'icelandic') + .addOption ('hy', 'armenian') + .addOption ('ne', 'nepali') + .addOption ('mn', 'mongolian') + .addOption ('bs', 'bosnian') + .addOption ('kk', 'kazakh') + .addOption ('sq', 'albanian') + .addOption ('sw', 'swahili') + .addOption ('gl', 'galician') + .addOption ('mr', 'marathi') + .addOption ('pa', 'punjabi') + .addOption ('si', 'sinhala') + .addOption ('km', 'khmer') + .addOption ('sn', 'shona') + .addOption ('yo', 'yoruba') + .addOption ('so', 'somali') + .addOption ('af', 'afrikaans') + .addOption ('oc', 'occitan') + .addOption ('ka', 'georgian') + .addOption ('be', 'belarusian') + .addOption ('tg', 'tajik') + .addOption ('sd', 'sindhi') + .addOption ('gu', 'gujarati') + .addOption ('am', 'amharic') + .addOption ('yi', 'yiddish') + .addOption ('lo', 'lao') + .addOption ('uz', 'uzbek') + .addOption ('fo', 'faroese') + .addOption ('ht', 'haitian creole') + .addOption ('ps', 'pashto') + .addOption ('tk', 'turkmen') + .addOption ('nn', 'nynorsk') + .addOption ('mt', 'maltese') + .addOption ('sa', 'sanskrit') + .addOption ('lb', 'luxembourgish') + .addOption ('my', 'myanmar') + .addOption ('bo', 'tibetan') + .addOption ('tl', 'tagalog') + .addOption ('mg', 'malagasy') + .addOption ('as', 'assamese') + .addOption ('tt', 'tatar') + .addOption ('ha', 'hawaiian') + .addOption ('ln', 'lingala') + .addOption ('ha', 'hausa') + .addOption ('ba', 'bashkir') + .addOption ('jw', 'javanese') + .addOption ('su', 'sundanese') + .addOption ('yu', 'cantonese') + .addOption ('en', 'english') + .addOption ('zh', 'chinese') + .addOption ('de', 'german') + .addOption ('es', 'spanish') + .addOption ('ru', 'russian') + .addOption ('ko', 'korean') + .addOption ('fr', 'french') + .addOption ('ja', 'japanese') + .addOption ('pt', 'portuguese') + .addOption ('tr', 'turkish') + .addOption ('pl', 'polish') + .addOption ('ca', 'catalan') + .addOption ('nl', 'dutch') + .addOption ('ar', 'arabic') + .addOption ('sv', 'swedish') + .addOption ('it', 'italian') + .addOption ('id', 'indonesian') + .addOption ('hi', 'hindi') + .addOption ('fi', 'finnish') + .addOption ('vi', 'vietnamese') + .addOption ('he', 'hebrew') + .addOption ('uk', 'ukrainian') + .addOption ('el', 'greek') + .addOption ('ms', 'malay') + .addOption ('cs', 'czech') + .addOption ('ro', 'romanian') + .addOption ('da', 'danish') + .addOption ('hu', 'hungarian') + .addOption ('ta', 'tamil') + .addOption ('no', 'norwegian') + .addOption ('th', 'thai') + .addOption ('ur', 'urdu') + .addOption ('hr', 'croatian') + .addOption ('bg', 'bulgarian') + .addOption ('lt', 'lithuanian') + .addOption ('la', 'latin') + .addOption ('mi', 'maori') + .addOption ('ml', 'malayalam') + .addOption ('cy', 'welsh') + .addOption ('sk', 'slovak') + .addOption ('te', 'telugu') + .addOption ('fa', 'persian') + .addOption ('lv', 'latvian') + .addOption ('bn', 'bengali') + .addOption ('sr', 'serbian') + .addOption ('az', 'azerbaijani') + .addOption ('sl', 'slovenian') + .addOption ('kn', 'kannada') + .addOption ('et', 'estonian') + .addOption ('mk', 'macedonian') + .addOption ('br', 'breton') + .addOption ('eu', 'basque') + .addOption ('is', 'icelandic') + .addOption ('hy', 'armenian') + .addOption ('ne', 'nepali') + .addOption ('mn', 'mongolian') + .addOption ('bs', 'bosnian') + .addOption ('kk', 'kazakh') + .addOption ('sq', 'albanian') + .addOption ('sw', 'swahili') + .addOption ('gl', 'galician') + .addOption ('mr', 'marathi') + .addOption ('pa', 'punjabi') + .addOption ('si', 'sinhala') + .addOption ('km', 'khmer') + .addOption ('sn', 'shona') + .addOption ('yo', 'yoruba') + .addOption ('so', 'somali') + .addOption ('af', 'afrikaans') + .addOption ('oc', 'occitan') + .addOption ('ka', 'georgian') + .addOption ('be', 'belarusian') + .addOption ('tg', 'tajik') + .addOption ('sd', 'sindhi') + .addOption ('gu', 'gujarati') + .addOption ('am', 'amharic') + .addOption ('yi', 'yiddish') + .addOption ('lo', 'lao') + .addOption ('uz', 'uzbek') + .addOption ('fo', 'faroese') + .addOption ('ht', 'haitian creole') + .addOption ('ps', 'pashto') + .addOption ('tk', 'turkmen') + .addOption ('nn', 'nynorsk') + .addOption ('mt', 'maltese') + .addOption ('sa', 'sanskrit') + .addOption ('lb', 'luxembourgish') + .addOption ('my', 'myanmar') + .addOption ('bo', 'tibetan') + .addOption ('tl', 'tagalog') + .addOption ('mg', 'malagasy') + .addOption ('as', 'assamese') + .addOption ('tt', 'tatar') + .addOption ('haw', 'hawaiian') + .addOption ('ln', 'lingala') + .addOption ('ha', 'hausa') + .addOption ('ba', 'bashkir') + .addOption ('jw', 'javanese') + .addOption ('su', 'sundanese') + .addOption ('yue', 'cantonese') + .setValue(this.plugin.settings.INPUT_LANGUAGE) + .onChange(async value => { + this.plugin.settings.INPUT_LANGUAGE = value as string; + await this.plugin.saveSettings(); + }); + }); + new Setting(containerEl) .setName('Temperature') .setDesc('The randomness of the generated text') diff --git a/src/include/ArcanaAgent.ts b/src/include/ArcanaAgent.ts index af80641..cfab6cf 100644 --- a/src/include/ArcanaAgent.ts +++ b/src/include/ArcanaAgent.ts @@ -33,7 +33,7 @@ export class ArcanaAgent { const transcription = await openai.audio.transcriptions.create({ file: file, model: 'whisper-1', - language: 'en', + language: this.arcana.settings.INPUT_LANGUAGE, }); return transcription.text; } diff --git a/src/include/ArcanaSettings.ts b/src/include/ArcanaSettings.ts index 7068ff7..103ceb0 100644 --- a/src/include/ArcanaSettings.ts +++ b/src/include/ArcanaSettings.ts @@ -7,6 +7,7 @@ export function isAvailableModel(model: string): model is AvailableModels { export default interface ArcanaSettings { OPEN_AI_API_KEY: string; MODEL_TYPE: AvailableModels; + INPUT_LANGUAGE: string; TEMPERATURE: number; TOP_P: number; //Plugins diff --git a/src/main.ts b/src/main.ts index 191f685..635d5b6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -28,6 +28,7 @@ import PoloPlugin from './plugins/Polo/Polo'; const DEFAULT_SETTINGS: ArcanaSettings = { OPEN_AI_API_KEY: '', MODEL_TYPE: 'gpt-3.5-turbo', + INPUT_LANGUAGE: 'en', TEMPERATURE: 0.7, TOP_P: 1, PluginSettings: {}, From dfb74cb47c6d6227016ec1542c2d18cd6a9401ee Mon Sep 17 00:00:00 2001 From: Oscar Neto Date: Thu, 28 Mar 2024 19:18:28 -0300 Subject: [PATCH 2/3] Enhanced description for the multilingual TTS setting Co-authored-by: A-F-V <59256018+A-F-V@users.noreply.github.com> --- src/components/ArcanaSettingsTab.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ArcanaSettingsTab.ts b/src/components/ArcanaSettingsTab.ts index 90bcfa1..bb85622 100644 --- a/src/components/ArcanaSettingsTab.ts +++ b/src/components/ArcanaSettingsTab.ts @@ -58,8 +58,8 @@ export default class ArcanaSettingsTab extends PluginSettingTab { }); new Setting(containerEl) - .setName('Input language') - .setDesc('If you use a language other than English to prompt, you need need to set it up otherwise the speech recognition will not work properly. Although, you probably also can use English without the need to change this setting again.') + .setName('Text to Speech Language') + .setDesc('The language used in AI's speech recognition') .addDropdown(dropdown => { dropdown .addOption ('en', 'english') From f685a58ba881cf340c426cda0f1fd2a7b87db8ce Mon Sep 17 00:00:00 2001 From: Oscar Neto Date: Thu, 28 Mar 2024 19:23:33 -0300 Subject: [PATCH 3/3] Fix quotation mark on TTS setting description --- src/components/ArcanaSettingsTab.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ArcanaSettingsTab.ts b/src/components/ArcanaSettingsTab.ts index bb85622..e288889 100644 --- a/src/components/ArcanaSettingsTab.ts +++ b/src/components/ArcanaSettingsTab.ts @@ -59,7 +59,7 @@ export default class ArcanaSettingsTab extends PluginSettingTab { new Setting(containerEl) .setName('Text to Speech Language') - .setDesc('The language used in AI's speech recognition') + .setDesc('The language used in AI\'s speech recognition') .addDropdown(dropdown => { dropdown .addOption ('en', 'english')