Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multilingual support for speech recognition #96

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 212 additions & 0 deletions src/components/ArcanaSettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,218 @@ export default class ArcanaSettingsTab extends PluginSettingTab {
});
});

new Setting(containerEl)
.setName('Input language')
oscaromsn marked this conversation as resolved.
Show resolved Hide resolved
.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.')
oscaromsn marked this conversation as resolved.
Show resolved Hide resolved
.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')
Expand Down
2 changes: 1 addition & 1 deletion src/include/ArcanaAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/include/ArcanaSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down