Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/default_device_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl DefaultDeviceSink {
let speed = inner.sink.speed();
let paused = inner.sink.is_paused();

let (stream, mut new_sink, name) = Self::create_stream();
let (stream, new_sink, name) = Self::create_stream();
new_sink.set_volume(volume);
new_sink.set_speed(speed);

Expand Down
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ use uuid::Uuid;
mod options;
#[cfg(target_os = "windows")]
mod windows_volume;
use speakstream::ss::SpeakStream;
use tracing::{debug, error, info, instrument, warn};
use tracing_appender::rolling::{RollingFileAppender, Rotation};

use speakstream::ss::SpeakStream;

#[derive(Debug, Subcommand)]
pub enum SubCommands {
/// Displays keys as you press them so you can figure out what key to use for push to talk.
Expand Down Expand Up @@ -1072,6 +1071,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
// It then sends the path of the recorded audio file to the AI thread.
let thread_llm_should_stop_mutex = llm_should_stop_mutex.clone();
let thread_speak_stream_mutex = speak_stream_mutex.clone();
let duck_ptt = opt.duck_ptt;
thread::spawn(move || {
let mut recorder = rec::Recorder::new();
let mut recording_start = std::time::SystemTime::now();
Expand Down Expand Up @@ -1100,6 +1100,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
let mut thread_speak_stream =
thread_speak_stream_mutex.lock().unwrap();
thread_speak_stream.stop_speech();
if duck_ptt {
thread_speak_stream.start_audio_ducking();
}
drop(thread_speak_stream);
}

Expand Down Expand Up @@ -1149,6 +1152,13 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
}

if duck_ptt {
let mut thread_speak_stream =
thread_speak_stream_mutex.lock().unwrap();
thread_speak_stream.stop_audio_ducking();
drop(thread_speak_stream);
}

// continue if we failed to get elapsed time
let elapsed = match elapsed_option {
Some(elapsed) => elapsed,
Expand Down
5 changes: 4 additions & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{SubCommands, VoiceEnum};
use clap::Parser;
use easy_rdev_key::PTTKey;

#[derive(Parser, Debug)]
#[command(version)]
Expand Down Expand Up @@ -33,6 +32,10 @@ pub struct Opt {
#[arg(long)]
pub tick: bool,

/// Duck other application audio while the push-to-talk key is held down.
#[arg(long)]
pub duck_ptt: bool,

/// Start with the AI voice muted.
#[arg(long)]
pub mute: bool,
Expand Down
Loading