Created
August 7, 2025 02:10
-
-
Save Quackdoc/cb0709589874405a7dd27765813eb3c2 to your computer and use it in GitHub Desktop.
transcribe mic and copy to clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/examples/basic_use.rs b/examples/basic_use.rs | |
| index 415371e..3af7689 100644 | |
| --- a/examples/basic_use.rs | |
| +++ b/examples/basic_use.rs | |
| @@ -43,13 +43,14 @@ fn main() { | |
| // note that you don't need to use these, you can do it yourself or any other way you want | |
| // these are just provided for convenience | |
| // SIMD variants of these functions are also available, but only on nightly Rust: see the docs | |
| + | |
| let mut inter_samples = vec![Default::default(); samples.len()]; | |
| whisper_rs::convert_integer_to_float_audio(&samples, &mut inter_samples) | |
| .expect("failed to convert audio data"); | |
| - let samples = whisper_rs::convert_stereo_to_mono_audio(&inter_samples) | |
| - .expect("failed to convert audio data"); | |
| - | |
| + //let samples = whisper_rs::convert_stereo_to_mono_audio(&inter_samples) | |
| + // .expect("failed to convert audio data"); | |
| + let samples = inter_samples; | |
| // now we can run the model | |
| // note the key we use here is the one we created above | |
| state | |
| @@ -70,6 +71,6 @@ fn main() { | |
| let end_timestamp = state | |
| .full_get_segment_t1(i) | |
| .expect("failed to get segment end timestamp"); | |
| - println!("[{} - {}]: {}", start_timestamp, end_timestamp, segment); | |
| + println!("{}", segment); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Find node using: pw-dump | jq '.[] | select(.info.props["media.class"] == "Audio/Source") | .info.props."node.name" + " | " + .info.props."node.description" + " | " + (.id|tostring)' | |
| # install example from | |
| # download from: git clone https://codeberg.org/tazz4843/whisper-rs | |
| # patch: git apply edit.patch | |
| # build: cargo build --release --example basic_use --features vulkan | |
| # install the file to wherever you want | |
| # Edit the script to use whatever paths you want | |
| if ! pidof pw-record > /dev/null; then | |
| TARGET=$(pw-dump | jq '.[] | select(.info.props["media.class"] == "Audio/Source") | select(.info.props["node.description"] == "DeepFilter Noise Canceling Source") | .id') | |
| #TARGET=$(pw-dump | jq '.[] | select(.info.props["media.class"] == "Audio/Source") | select(.info.props["node.description"] == "Realtek Audio USB Analog Stereo") | .id') | |
| if [ -n "$TARGET" ]; then | |
| #echo "Recording started with target: $TARGET" | |
| timeout 30s pw-record --target "$TARGET" --channels 1 --rate 16000 --format s16 /tmp/record.wav | |
| notify-send "transcribing" | |
| /home/quack/.cargo/bin/whisper-rs-cli /home/quack/.local/ggml-small.en.bin /tmp/record.wav 2>/tmp/error.log | wl-copy | |
| notify-send "transcription saved to clipboard" | |
| #echo "$(env)" > /tmp/env.log | |
| #rm /tmp/record.wav | |
| else | |
| echo "No suitable audio source found." | |
| fi | |
| else | |
| pkill pw-record | |
| echo "pw-record process killed." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment