Skip to content

Commit

Permalink
Merge pull request #96 from oscaromsn/master
Browse files Browse the repository at this point in the history
Add multilingual support for speech recognition
  • Loading branch information
A-F-V authored Apr 3, 2024
2 parents 2428c10 + f685a58 commit 8682be3
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 1 deletion.
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('Text to Speech Language')
.setDesc('The language used in AI\'s speech recognition')
.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

0 comments on commit 8682be3

Please sign in to comment.