diff --git a/src-tauri/migrations/001.sql b/src-tauri/migrations/001.sql index f9c2196..168b89f 100644 --- a/src-tauri/migrations/001.sql +++ b/src-tauri/migrations/001.sql @@ -11,7 +11,7 @@ CREATE TABLE speeches ( content TEXT, wav TEXT, model TEXT, -- manual|vosk|whisper - model_description TEXT, -- ja-0.22|small-ja-0.22|en-us-0.22|small-en-us-0.15|small|medium|large + model_description TEXT, -- ja-0.22|small-ja-0.22|en-us-0.22|small-en-us-0.15|cn-0.22|small-cn-0.22|small-ko-0.22|fr-0.22|small-fr-0.22|de-0.21|small-de-0.15|ru-0.42|small-ru-0.22|es-0.42|small-es-0.42|small-pt-0.3|small-tr-0.3|vn-0.4|small-vn-0.4|it-0.22|small-it-0.22|small-nl-0.22|small-ca-0.4|small-uk-v3-small|uk-v3|small-sv-rhasspy-0.15|small-hi-0.22|hi-0.22|small-cs-0.4-rhasspy|small-pl-0.22|small|medium|large note_id INTEGER NOT NULL, FOREIGN KEY(note_id) REFERENCES notes(id) ); @@ -40,5 +40,31 @@ INSERT INTO models(model_name, model_type) VALUES("tiny", "whisper"); INSERT INTO models(model_name, model_type) VALUES("tiny.en", "whisper"); INSERT INTO models(model_name, model_type) VALUES("ja-0.22", "vosk"); INSERT INTO models(model_name, model_type) VALUES("en-us-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("cn-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("fr-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("de-0.21", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("ru-0.42", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("es-0.42", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("vn-0.4", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("it-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("uk-v3", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("hi-0.22", "vosk"); INSERT INTO models(model_name, model_type) VALUES("small-ja-0.22", "vosk"); INSERT INTO models(model_name, model_type) VALUES("small-en-us-0.15", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-cn-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-ko-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-fr-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-de-0.15", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-ru-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-es-0.42", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-pt-0.3", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-tr-0.3", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-vn-0.4", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-it-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-nl-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-ca-0.4", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-uk-v3-small", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-sv-rhasspy-0.15", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-hi-0.22", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-cs-0.4-rhasspy", "vosk"); +INSERT INTO models(model_name, model_type) VALUES("small-pl-0.22", "vosk"); diff --git a/src-tauri/resources/COPYING b/src-tauri/resources/COPYING deleted file mode 100644 index 3e4f619..0000000 --- a/src-tauri/resources/COPYING +++ /dev/null @@ -1,176 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. this License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/src-tauri/resources/NOTICE b/src-tauri/resources/NOTICE index e22c890..d509929 100644 --- a/src-tauri/resources/NOTICE +++ b/src-tauri/resources/NOTICE @@ -1,2 +1,2 @@ -The Developer of the ASR models is Alpha Cephei Inc (https://alphacephei.com/e). -Copyright 2019 Alpha Cephei Inc. All Rights Reserved. \ No newline at end of file +The Developer of the ASR models is Alpha Cephei Inc (https://alphacephei.com/). +Copyright Alpha Cephei Inc. All Rights Reserved. \ No newline at end of file diff --git a/src-tauri/resources/whisper/.gitkeep b/src-tauri/resources/whisper/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src-tauri/src/module/model_type_vosk.rs b/src-tauri/src/module/model_type_vosk.rs index f48bcff..fa36ac9 100644 --- a/src-tauri/src/module/model_type_vosk.rs +++ b/src-tauri/src/module/model_type_vosk.rs @@ -5,6 +5,32 @@ pub enum ModelTypeVosk { Japanese, SmallEnglish, English, + SmallChinese, + Chinese, + SmallKorean, + SmallFrench, + French, + SmallGerman, + German, + SmallRussian, + Russian, + SmallSpanish, + Spanish, + SmallPortuguese, + SmallTurkish, + SmallVietnamese, + Vietnamese, + SmallItalian, + Italian, + SmallDutch, + SmallCatalan, + SmallUkrainian, + Ukrainian, + SmallSwedish, + SmallHindi, + Hindi, + SmallCzech, + SmallPolish, } impl ModelTypeVosk { @@ -14,6 +40,32 @@ impl ModelTypeVosk { ModelTypeVosk::Japanese => "ja-0.22", ModelTypeVosk::SmallEnglish => "small-en-us-0.15", ModelTypeVosk::English => "en-us-0.22", + ModelTypeVosk::SmallChinese => "small-cn-0.22", + ModelTypeVosk::Chinese => "cn-0.22", + ModelTypeVosk::SmallKorean => "small-ko-0.22", + ModelTypeVosk::SmallFrench => "small-fr-0.22", + ModelTypeVosk::French => "fr-0.22", + ModelTypeVosk::SmallGerman => "small-de-0.15", + ModelTypeVosk::German => "de-0.21", + ModelTypeVosk::SmallRussian => "small-ru-0.22", + ModelTypeVosk::Russian => "ru-0.42", + ModelTypeVosk::SmallSpanish => "small-es-0.42", + ModelTypeVosk::Spanish => "es-0.42", + ModelTypeVosk::SmallPortuguese => "small-pt-0.3", + ModelTypeVosk::SmallTurkish => "small-tr-0.3", + ModelTypeVosk::SmallVietnamese => "small-vn-0.4", + ModelTypeVosk::Vietnamese => "vn-0.4", + ModelTypeVosk::SmallItalian => "small-it-0.22", + ModelTypeVosk::Italian => "it-0.22", + ModelTypeVosk::SmallDutch => "small-nl-0.22", + ModelTypeVosk::SmallCatalan => "small-ca-0.4", + ModelTypeVosk::SmallUkrainian => "small-uk-v3-small", + ModelTypeVosk::Ukrainian => "uk-v3", + ModelTypeVosk::SmallSwedish => "small-sv-rhasspy-0.15", + ModelTypeVosk::SmallHindi => "small-hi-0.22", + ModelTypeVosk::Hindi => "hi-0.22", + ModelTypeVosk::SmallCzech => "small-cs-0.4-rhasspy", + ModelTypeVosk::SmallPolish => "small-pl-0.22", } } } @@ -27,6 +79,32 @@ impl FromStr for ModelTypeVosk { "ja-0.22" => Ok(ModelTypeVosk::Japanese), "small-en-us-0.15" => Ok(ModelTypeVosk::SmallEnglish), "en-us-0.22" => Ok(ModelTypeVosk::English), + "small-cn-0.22" => Ok(ModelTypeVosk::SmallChinese), + "cn-0.22" => Ok(ModelTypeVosk::Chinese), + "small-ko-0.22" => Ok(ModelTypeVosk::SmallKorean), + "small-fr-0.22" => Ok(ModelTypeVosk::SmallFrench), + "fr-0.22" => Ok(ModelTypeVosk::French), + "small-de-0.15" => Ok(ModelTypeVosk::SmallGerman), + "de-0.21" => Ok(ModelTypeVosk::German), + "small-ru-0.22" => Ok(ModelTypeVosk::SmallRussian), + "ru-0.42" => Ok(ModelTypeVosk::Russian), + "small-es-0.42" => Ok(ModelTypeVosk::SmallSpanish), + "es-0.42" => Ok(ModelTypeVosk::Spanish), + "small-pt-0.3" => Ok(ModelTypeVosk::SmallPortuguese), + "small-tr-0.3" => Ok(ModelTypeVosk::SmallTurkish), + "small-vn-0.4" => Ok(ModelTypeVosk::SmallVietnamese), + "vn-0.4" => Ok(ModelTypeVosk::Vietnamese), + "small-it-0.22" => Ok(ModelTypeVosk::SmallItalian), + "it-0.22" => Ok(ModelTypeVosk::Italian), + "small-nl-0.22" => Ok(ModelTypeVosk::SmallDutch), + "small-ca-0.4" => Ok(ModelTypeVosk::SmallCatalan), + "small-uk-v3-small" => Ok(ModelTypeVosk::SmallUkrainian), + "uk-v3" => Ok(ModelTypeVosk::Ukrainian), + "small-sv-rhasspy-0.15" => Ok(ModelTypeVosk::SmallSwedish), + "small-hi-0.22" => Ok(ModelTypeVosk::SmallHindi), + "hi-0.22" => Ok(ModelTypeVosk::Hindi), + "small-cs-0.4-rhasspy" => Ok(ModelTypeVosk::SmallCzech), + "small-pl-0.22" => Ok(ModelTypeVosk::SmallPolish), _ => Err(()), } } diff --git a/src-tauri/src/module/transcriber.rs b/src-tauri/src/module/transcriber.rs index 74aaa15..543ba33 100644 --- a/src-tauri/src/module/transcriber.rs +++ b/src-tauri/src/module/transcriber.rs @@ -7,12 +7,17 @@ pub struct Transcriber {} impl Transcriber { pub fn build(app_handle: AppHandle, transcription_accuracy: String) -> WhisperContext { + let mut model_type = ""; + if transcription_accuracy.starts_with("small") { + model_type = "small"; + } else if transcription_accuracy.starts_with("medium") { + model_type = "medium" + } else if transcription_accuracy.starts_with("large") { + model_type = "large" + } let model_path = app_handle .path_resolver() - .resolve_resource(format!( - "resources/whisper/ggml-{}.bin", - transcription_accuracy - )) + .resolve_resource(format!("resources/whisper/ggml-{}.bin", model_type)) .unwrap() .to_string_lossy() .to_string(); @@ -20,10 +25,47 @@ impl Transcriber { return WhisperContext::new(&model_path).expect("failed to load whisper model"); } - pub fn build_params(speaker_language: String) -> FullParams<'static, 'static> { + pub fn build_params( + speaker_language: String, + transcription_accuracy: String, + ) -> FullParams<'static, 'static> { let mut language = "ja"; if speaker_language.starts_with("en-us") || speaker_language.starts_with("small-en-us") { language = "en"; + } else if speaker_language.starts_with("cn") || speaker_language.starts_with("small-cn") { + language = "zh"; + } else if speaker_language.starts_with("small-ko") { + language = "ko"; + } else if speaker_language.starts_with("fr") || speaker_language.starts_with("small-fr") { + language = "fr"; + } else if speaker_language.starts_with("de") || speaker_language.starts_with("small-de") { + language = "de"; + } else if speaker_language.starts_with("ru") || speaker_language.starts_with("small-ru") { + language = "ru"; + } else if speaker_language.starts_with("es") || speaker_language.starts_with("small-es") { + language = "es"; + } else if speaker_language.starts_with("small-pt") { + language = "pt"; + } else if speaker_language.starts_with("small-tr") { + language = "tr"; + } else if speaker_language.starts_with("vn") || speaker_language.starts_with("small-vn") { + language = "vi"; + } else if speaker_language.starts_with("it") || speaker_language.starts_with("small-it") { + language = "it"; + } else if speaker_language.starts_with("small-nl") { + language = "nl"; + } else if speaker_language.starts_with("small-ca") { + language = "ca"; + } else if speaker_language.starts_with("uk") || speaker_language.starts_with("small-uk") { + language = "uk"; + } else if speaker_language.starts_with("small-sv") { + language = "sv"; + } else if speaker_language.starts_with("hi") || speaker_language.starts_with("small-hi") { + language = "hi"; + } else if speaker_language.starts_with("small-cs") { + language = "cs"; + } else if speaker_language.starts_with("small-pl") { + language = "pl"; } let mut params = FullParams::new(SamplingStrategy::BeamSearch { beam_size: 5, @@ -35,7 +77,11 @@ impl Transcriber { ); println!("working on {} threads.", hardware_concurrency); params.set_n_threads(hardware_concurrency); - params.set_translate(false); + if transcription_accuracy.ends_with("en") { + params.set_translate(true); + } else { + params.set_translate(false); + } params.set_language(Some(language)); params.set_print_special(false); params.set_print_progress(false); diff --git a/src-tauri/src/module/transcription.rs b/src-tauri/src/module/transcription.rs index e47433d..716c298 100644 --- a/src-tauri/src/module/transcription.rs +++ b/src-tauri/src/module/transcription.rs @@ -15,6 +15,7 @@ pub struct Transcription { sqlite: Sqlite, ctx: WhisperContext, speaker_language: String, + transcription_accuracy: String, note_id: u64, } @@ -29,8 +30,9 @@ impl Transcription { Self { app_handle, sqlite: Sqlite::new(), - ctx: Transcriber::build(app_handle_clone, transcription_accuracy), + ctx: Transcriber::build(app_handle_clone, transcription_accuracy.clone()), speaker_language, + transcription_accuracy, note_id, } } @@ -42,10 +44,7 @@ impl Transcription { if vosk_speech.is_err() { self.app_handle .clone() - .emit_all( - "traceCompletion", - TraceCompletion {}, - ) + .emit_all("traceCompletion", TraceCompletion {}) .unwrap(); break; } @@ -55,18 +54,12 @@ impl Transcription { if vosk_speech.is_err() { self.app_handle .clone() - .emit_all( - "traceCompletion", - TraceCompletion {}, - ) + .emit_all("traceCompletion", TraceCompletion {}) .unwrap(); } else { self.app_handle .clone() - .emit_all( - "traceUnCompletion", - TraceCompletion {}, - ) + .emit_all("traceUnCompletion", TraceCompletion {}) .unwrap(); } break; @@ -126,7 +119,10 @@ impl Transcription { // let mut ctx = Transcriber::build(self.app_handle.clone()); // let mut ctx = self.ctx; let result = self.ctx.full( - Transcriber::build_params(self.speaker_language.clone()), + Transcriber::build_params( + self.speaker_language.clone(), + self.transcription_accuracy.clone(), + ), &audio_data[..], ); if result.is_ok() { diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 8bfccaa..64ead4f 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "Lycoris", - "version": "0.6.0" + "version": "0.7.0" }, "tauri": { "allowlist": { diff --git a/src/components/molecules/SettingLanguages.tsx b/src/components/molecules/SettingLanguages.tsx new file mode 100644 index 0000000..dd9b728 --- /dev/null +++ b/src/components/molecules/SettingLanguages.tsx @@ -0,0 +1,25 @@ +import { ChangeEvent } from "react"; +import { useRecoilState, useRecoilValue } from 'recoil'; +import { recordState } from "../../store/atoms/recordState"; +import { settingLanguageState } from "../../store/atoms/settingLanguageState"; + +const SettingLanguages = (): JSX.Element => { + const settingLanguages = ["日本語", "英語", "中国語", "韓国語", "フランス語", "ドイツ語", "ロシア語", "スペイン語", "ポルトガル語", "トルコ語", "ベトナム語", "イタリア語", "オランダ語", "カタルーニャ語", "ウクライナ語", "スウェーデン語", "ヒンディー語", "チェコ語", "ポーランド語"] + const [settingLanguage, setSettingLanguage] = useRecoilState(settingLanguageState) + const isRecording = useRecoilValue(recordState) + + const change = (e: ChangeEvent) => { + const settingLanguage = e.target.value + setSettingLanguage(settingLanguage) + } + + return ( + + ) +} + +export { SettingLanguages } diff --git a/src/components/molecules/SpeakerLanguage.tsx b/src/components/molecules/SpeakerLanguage.tsx index 223b834..b4e92cf 100644 --- a/src/components/molecules/SpeakerLanguage.tsx +++ b/src/components/molecules/SpeakerLanguage.tsx @@ -24,6 +24,58 @@ const SpeakerLanguage = (): JSX.Element => { return "英語:低"; case "en-us-0.22": return "英語"; + case "small-cn-0.22": + return "中国語:低"; + case "cn-0.22": + return "中国語"; + case "small-ko-0.22": + return "韓国語:低"; + case "small-fr-0.22": + return "フランス語:低"; + case "fr-0.22": + return "フランス語"; + case "small-de-0.15": + return "ドイツ語:低"; + case "de-0.21": + return "ドイツ語"; + case "small-ru-0.22": + return "ロシア語:低"; + case "ru-0.42": + return "ロシア語"; + case "small-es-0.42": + return "スペイン語:低"; + case "es-0.42": + return "スペイン語"; + case "small-pt-0.3": + return "ポルトガル語:低"; + case "small-tr-0.3": + return "トルコ語:低"; + case "small-vn-0.4": + return "ベトナム語:低"; + case "vn-0.4": + return "ベトナム語"; + case "small-it-0.22": + return "イタリア語:低"; + case "it-0.22": + return "イタリア語"; + case "small-nl-0.22": + return "オランダ語:低"; + case "small-ca-0.4": + return "カタルーニャ語:低"; + case "small-uk-v3-small": + return "ウクライナ語:低"; + case "uk-v3": + return "ウクライナ語"; + case "small-sv-rhasspy-0.15": + return "スウェーデン語:低"; + case "small-hi-0.22": + return "ヒンディー語:低"; + case "hi-0.22": + return "ヒンディー語"; + case "small-cs-0.4-rhasspy": + return "チェコ語:低"; + case "small-pl-0.22": + return "ポーランド語:低"; default: throw new Error("unknown modelType"); } diff --git a/src/components/molecules/TranscriptionAccuracy.tsx b/src/components/molecules/TranscriptionAccuracy.tsx index 3d279c8..8007b72 100644 --- a/src/components/molecules/TranscriptionAccuracy.tsx +++ b/src/components/molecules/TranscriptionAccuracy.tsx @@ -3,11 +3,13 @@ import { useRecoilState, useRecoilValue } from 'recoil'; import { transcriptionAccuracyState } from "../../store/atoms/transcriptionAccuracyState"; import { modelWhisperDownloadedState } from "../../store/atoms/modelWhisperDownloadedState"; import { recordState } from "../../store/atoms/recordState"; +import { speakerLanguageState } from "../../store/atoms/speakerLanguageState"; const TranscriptionAccuracy = (): JSX.Element => { const downloadedModels = useRecoilValue(modelWhisperDownloadedState) const [transcriptionAccuracy, setTranscriptionAccuracy] = useRecoilState(transcriptionAccuracyState) const isRecording = useRecoilValue(recordState) + const speakerLanguage = useRecoilValue(speakerLanguageState) const change = (e: ChangeEvent) => { const transcriptionAccuracy = e.target.value @@ -17,11 +19,17 @@ const TranscriptionAccuracy = (): JSX.Element => { const mapModel = (model: string) => { switch (model) { case "small": - return "文字起こし:小"; + return "文字起こし:低"; case "medium": return "文字起こし:中"; case "large": return "文字起こし:高"; + case "small-translate-to-en": + return "翻訳(英):低"; + case "medium-translate-to-en": + return "翻訳(英):中"; + case "large-translate-to-en": + return "翻訳(英):高"; default: throw new Error("unknown modelType"); } @@ -31,7 +39,12 @@ const TranscriptionAccuracy = (): JSX.Element => { diff --git a/src/components/organisms/NoteMain.tsx b/src/components/organisms/NoteMain.tsx index c9cd972..c48c7ec 100644 --- a/src/components/organisms/NoteMain.tsx +++ b/src/components/organisms/NoteMain.tsx @@ -115,6 +115,7 @@ const NoteMain = (): JSX.Element => { {(isRecording && recordingNote === selectedNote?.note_id) ? : }
+
フィルター: diff --git a/src/components/organisms/SettingsMain.tsx b/src/components/organisms/SettingsMain.tsx index b6acd60..883220b 100644 --- a/src/components/organisms/SettingsMain.tsx +++ b/src/components/organisms/SettingsMain.tsx @@ -1,19 +1,23 @@ +import { useRecoilValue } from "recoil" +import { settingLanguageState } from "../../store/atoms/settingLanguageState" import { ModelDownloadVoskButton } from "../molecules/ModelDownloadVoskButton" import { ModelDownloadVoskProgress } from "../molecules/ModelDownloadVoskProgress" import { ModelDownloadWhisperButton } from "../molecules/ModelDownloadWhisperButton" import { ModelDownloadWhisperProgress } from "../molecules/ModelDownloadWhisperProgress" +import { SettingLanguages } from "../molecules/SettingLanguages" const SettingsMain = (): JSX.Element => { + const settingLanguage = useRecoilValue(settingLanguageState); return (
-

+

設定

-
+

@@ -25,37 +29,260 @@ const SettingsMain = (): JSX.Element => {

音声認識を行う対象言語の、言語パックをダウンロードしてください。

なお利用メモリが切迫している場合は、低容量版がオススメです。

-
-
-

言語パック(日本語:低)

- -
- +
+
-
-
-

言語パック(日本語)

- + {settingLanguage === "日本語" && <> +
+
+

言語パック(日本語:低)

+ +
+
- -
-
-
-

言語パック(英語:低)

- +
+
+

言語パック(日本語)

+ +
+
- -
-
-
-

言語パック(英語)

- + } + {settingLanguage === "英語" && <> +
+
+

言語パック(英語:低)

+ +
+
- -
+
+
+

言語パック(英語)

+ +
+ +
+ } + {settingLanguage === "中国語" && <> +
+
+

言語パック(中国語:低)

+ +
+ +
+
+
+

言語パック(中国語)

+ +
+ +
+ } + {settingLanguage === "韓国語" && <> +
+
+

言語パック(韓国語:低)

+ +
+ +
+ } + {settingLanguage === "フランス語" && <> +
+
+

言語パック(フランス語:低)

+ +
+ +
+
+
+

言語パック(フランス語)

+ +
+ +
+ } + {settingLanguage === "ドイツ語" && <> +
+
+

言語パック(ドイツ語:低)

+ +
+ +
+
+
+

言語パック(ドイツ語)

+ +
+ +
+ } + {settingLanguage === "ロシア語" && <> +
+
+

言語パック(ロシア語:低)

+ +
+ +
+
+
+

言語パック(ロシア語)

+ +
+ +
+ } + {settingLanguage === "スペイン語" && <> +
+
+

言語パック(スペイン語:低)

+ +
+ +
+
+
+

言語パック(スペイン語)

+ +
+ +
+ } + {settingLanguage === "ポルトガル語" && <> +
+
+

言語パック(ポルトガル語:低)

+ +
+ +
+ } + {settingLanguage === "トルコ語" && <> +
+
+

言語パック(トルコ語:低)

+ +
+ +
+ } + {settingLanguage === "ベトナム語" && <> +
+
+

言語パック(ベトナム語:低)

+ +
+ +
+
+
+

言語パック(ベトナム語)

+ +
+ +
+ } + {settingLanguage === "イタリア語" && <> +
+
+

言語パック(イタリア語:低)

+ +
+ +
+
+
+

言語パック(イタリア語)

+ +
+ +
+ } + {settingLanguage === "オランダ語" && <> +
+
+

言語パック(オランダ語:低)

+ +
+ +
+ } + {settingLanguage === "カタルーニャ語" && <> +
+
+

言語パック(カタルーニャ語:低)

+ +
+ +
+ } + {settingLanguage === "ウクライナ語" && <> +
+
+

言語パック(ウクライナ語:低)

+ +
+ +
+
+
+

言語パック(ウクライナ語)

+ +
+ +
+ } + {settingLanguage === "スウェーデン語" && <> +
+
+

言語パック(スウェーデン語:低)

+ +
+ +
+ } + {settingLanguage === "ヒンディー語" && <> +
+
+

言語パック(ヒンディー語:低)

+ +
+ +
+
+
+

言語パック(ヒンディー語)

+ +
+ +
+ } + {settingLanguage === "チェコ語" && <> +
+
+

言語パック(チェコ語:低)

+ +
+ +
+ } + {settingLanguage === "ポーランド語" && <> +
+
+

言語パック(ポーランド語:低)

+ +
+ +
+ }
-
+

@@ -69,7 +296,7 @@ const SettingsMain = (): JSX.Element => {

-

言語パック(精度:小)

+

言語パック(精度:低)

diff --git a/src/store/atoms/settingLanguageState.ts b/src/store/atoms/settingLanguageState.ts new file mode 100644 index 0000000..8b43a65 --- /dev/null +++ b/src/store/atoms/settingLanguageState.ts @@ -0,0 +1,31 @@ +import { atom, AtomEffect } from 'recoil' +import DB from '../../lib/sqlite'; + +const sqliteEffect: AtomEffect = ({setSelf, onSet, trigger}) => { + const loadPersisted = async () => { + const db = (await DB.getInstance()) + const savedValue = await db.loadSetting("settingLanguage"); + setSelf(savedValue!.setting_status); + }; + + if (trigger === 'get') { + loadPersisted(); + } + + onSet(async(newValue, _, isReset:any) => { + const db = await DB.getInstance() + if (isReset) { + await db.updateSetting("settingLanguage", "日本語") + } else { + await db.updateSetting("settingLanguage", newValue) + } + }); +}; + +export const settingLanguageState = atom({ + key: 'settingLanguageState', + default: "日本語", + effects: [ + sqliteEffect, + ] +}) \ No newline at end of file