From e5295497e8fcb1cdfe03ecae0be14a3f426fe8e8 Mon Sep 17 00:00:00 2001 From: Kodai Aoyama Date: Tue, 21 May 2024 23:30:26 +0900 Subject: [PATCH 1/6] frontend logic --- src-tauri/migrations/001.sql | 2 + src-tauri/src/module/sqlite.rs | 8 ++++ .../molecules/SettingAmiVoiceModel.tsx | 42 +++++++++++++++++++ .../molecules/TranscriptionAccuracy.tsx | 12 +++++- src/components/organisms/SettingsMain.tsx | 20 +++++++++ 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/components/molecules/SettingAmiVoiceModel.tsx diff --git a/src-tauri/migrations/001.sql b/src-tauri/migrations/001.sql index 3d50421..734a9a1 100644 --- a/src-tauri/migrations/001.sql +++ b/src-tauri/migrations/001.sql @@ -44,6 +44,8 @@ VALUES("settingResource", ""); INSERT INTO settings(setting_name, setting_status) VALUES("settingModel", "gpt-3.5-turbo"); INSERT INTO settings(setting_name, setting_status) +VALUES("settingAmiVoiceModel", "general"); +INSERT INTO settings(setting_name, setting_status) VALUES("settingAILanguage", "None"); INSERT INTO settings(setting_name, setting_status) VALUES( diff --git a/src-tauri/src/module/sqlite.rs b/src-tauri/src/module/sqlite.rs index 788bdcc..08aa355 100644 --- a/src-tauri/src/module/sqlite.rs +++ b/src-tauri/src/module/sqlite.rs @@ -100,6 +100,14 @@ impl Sqlite { ); } + pub fn select_amivoice_model(&self) -> Result { + return self.conn.query_row( + "SELECT setting_status FROM settings WHERE setting_name = \"settingAmiVoiceModel\"", + params![], + |row| Ok(row.get_unwrap(0)), + ); + } + pub fn select_ai_resource(&self) -> Result { return self.conn.query_row( "SELECT setting_status FROM settings WHERE setting_name = \"settingResource\"", diff --git a/src/components/molecules/SettingAmiVoiceModel.tsx b/src/components/molecules/SettingAmiVoiceModel.tsx new file mode 100644 index 0000000..eabd3a5 --- /dev/null +++ b/src/components/molecules/SettingAmiVoiceModel.tsx @@ -0,0 +1,42 @@ +import { ChangeEvent } from "react"; +import { useRecoilState } from 'recoil'; +import { settingKeyState } from "../../store/atoms/settingKeyState"; + +const SettingAmiVoiceModel = (): JSX.Element => { + const settingModels = ["general", "medgeneral", "bizmrreport", "bizfinance", "bizinsurance"] as const; + const modelNameMapper = (model: typeof settingModels[number])=>{ + switch(model){ + case "general": + return "汎用" + case "medgeneral": + return "医療" + case "bizmrreport": + return "製薬" + case "bizfinance": + return "金融" + case "bizinsurance": + return "保険" + } + } + const [settingKey, setSettingKey] = useRecoilState(settingKeyState("settingAmiVoiceModel")) + + const change = (e: ChangeEvent) => { + const settingKey = e.target.value + setSettingKey(settingKey) + } + + return ( +
+

利用モデル

+
+ +
+
+ ) +} + +export { SettingAmiVoiceModel } diff --git a/src/components/molecules/TranscriptionAccuracy.tsx b/src/components/molecules/TranscriptionAccuracy.tsx index 7d7c953..a041e22 100644 --- a/src/components/molecules/TranscriptionAccuracy.tsx +++ b/src/components/molecules/TranscriptionAccuracy.tsx @@ -14,6 +14,7 @@ const TranscriptionAccuracy = (): JSX.Element => { const isTracing = useRecoilValue(tracingState); const speakerLanguage = useRecoilValue(speakerLanguageState) const settingKeyOpenai = useRecoilValue(settingKeyState("settingKeyOpenai")) + const settingKeyAmivoice = useRecoilValue(settingKeyState("settingKeyAmivoice")) const dropdownRef = useRef(null) @@ -47,6 +48,8 @@ const TranscriptionAccuracy = (): JSX.Element => { return "文字起こし:日"; case "online-transcript": return "文字起こし:オンライン"; + case "online-amivoice": + return "文字起こし:AmiVoice"; case "online-chat": return "AI:オンライン"; case "small-translate-to-en": @@ -62,7 +65,7 @@ const TranscriptionAccuracy = (): JSX.Element => { return (
- {((isRecording || isTracing) || downloadedModels.length === 0) ?