diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index efc5092..be03186 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -94,6 +94,7 @@ fn start_command( transcription_accuracy, note_id, stop_record_rx, + Arc::new(Mutex::new(false)), ); } else if device_type == "desktop" { let record_desktop = @@ -104,6 +105,7 @@ fn start_command( note_id, stop_record_rx, None, + Arc::new(Mutex::new(false)), ); } else { let record = module::record::Record::new(window.app_handle().clone()); @@ -112,21 +114,29 @@ fn start_command( let (stop_record_clone_tx, stop_record_clone_rx) = unbounded(); let speaker_language_clone = speaker_language.clone(); + let transcription_accuracy_clone = transcription_accuracy.clone(); + + let should_stop_other_transcription = Arc::new(Mutex::new(false)); + let should_stop_other_transcription_clone = + Arc::clone(&should_stop_other_transcription); + std::thread::spawn(move || { record_desktop.start( speaker_language_clone, - transcription_accuracy, + transcription_accuracy_clone, note_id, stop_record_rx, Some(stop_record_clone_tx), + should_stop_other_transcription_clone, ); }); record.start( device_label, speaker_language, - "off".to_string(), + transcription_accuracy, note_id, stop_record_clone_rx.clone(), + should_stop_other_transcription, ); } }); diff --git a/src-tauri/src/module/record.rs b/src-tauri/src/module/record.rs index 07806b9..4dfaa41 100644 --- a/src-tauri/src/module/record.rs +++ b/src-tauri/src/module/record.rs @@ -43,7 +43,16 @@ impl Record { transcription_accuracy: String, note_id: u64, stop_record_rx: Receiver<()>, + should_stop_other_transcription: Arc>, ) { + let should_stop_other_transcription_on_record = + *should_stop_other_transcription.lock().unwrap(); + if !should_stop_other_transcription_on_record { + let mut lock = should_stop_other_transcription.lock().unwrap(); + *lock = true; + drop(lock); + } + let host = cpal::default_host(); let device = host .input_devices() @@ -175,12 +184,16 @@ impl Record { .lock() .unwrap() .replace(Writer::build(&audio_path.to_str().expect("error"), spec)); - if !is_no_transcription && !*is_converting.lock().unwrap() { + if !is_no_transcription + && !*is_converting.lock().unwrap() + && !should_stop_other_transcription_on_record + { let is_converting_clone = Arc::clone(&is_converting); let app_handle_clone = app_handle.clone(); let stop_convert_rx_clone = stop_convert_rx.clone(); let transcription_accuracy_clone = transcription_accuracy.clone(); let speaker_language_clone = speaker_language.clone(); + std::thread::spawn(move || { let mut lock = is_converting_clone.lock().unwrap(); *lock = true; diff --git a/src-tauri/src/module/record_desktop.rs b/src-tauri/src/module/record_desktop.rs index 4eb028f..9e93273 100644 --- a/src-tauri/src/module/record_desktop.rs +++ b/src-tauri/src/module/record_desktop.rs @@ -103,7 +103,16 @@ impl RecordDesktop { note_id: u64, stop_record_rx: Receiver<()>, stop_record_clone_tx: Option>, + should_stop_other_transcription: Arc>, ) { + let should_stop_other_transcription_on_record_desktop = + *should_stop_other_transcription.lock().unwrap(); + if !should_stop_other_transcription_on_record_desktop { + let mut lock = should_stop_other_transcription.lock().unwrap(); + *lock = true; + drop(lock); + } + let mut current = SCShareableContent::current(); let display = current.displays.pop().unwrap(); @@ -206,12 +215,16 @@ impl RecordDesktop { .lock() .unwrap() .replace(Writer::build(&audio_path.to_str().expect("error"), spec)); - if !is_no_transcription && !*is_converting.lock().unwrap() { + if !is_no_transcription + && !*is_converting.lock().unwrap() + && !should_stop_other_transcription_on_record_desktop + { let is_converting_clone = Arc::clone(&is_converting); let app_handle_clone = app_handle.clone(); let stop_convert_rx_clone = stop_convert_rx.clone(); let transcription_accuracy_clone = transcription_accuracy.clone(); let speaker_language_clone = speaker_language.clone(); + std::thread::spawn(move || { let mut lock = is_converting_clone.lock().unwrap(); *lock = true; diff --git a/src/components/molecules/AudioDevice.tsx b/src/components/molecules/AudioDevice.tsx index f0fbfab..24c669d 100644 --- a/src/components/molecules/AudioDevice.tsx +++ b/src/components/molecules/AudioDevice.tsx @@ -103,7 +103,7 @@ const AudioDevices = (): JSX.Element => {
利用する音源 + group-hover:visible opacity-100 absolute">利用する音源
: - {showAudioSource &&
    + {showAudioSource &&
      {audioDevices.map((device, i) => (