From bf1d5d5859c4d657cf20985aad3673b8d37b7293 Mon Sep 17 00:00:00 2001 From: Nik King Date: Tue, 7 Oct 2025 08:32:20 -0500 Subject: [PATCH 1/3] Change default url to production --- README.md | 6 +++--- flake.nix | 22 ++++++++++++++++++++++ src/stt_client.rs | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 flake.nix diff --git a/README.md b/README.md index 505fd4c..e9e3e3e 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ sudo -E ./target/debug/voice-keyboard --test-stt ## Speech-to-Text Service -This application uses **Deepgram Flux**, the company's new turn‑taking STT API. The default WebSocket URL is `wss://api.preview.deepgram.com/v2/listen`. +This application uses **Deepgram Flux**, the company's new turn‑taking STT API. The default WebSocket URL is `wss://api.deepgram.com/v2/listen`. ## Command Line Options @@ -89,7 +89,7 @@ OPTIONS: --test-audio Test audio input and show levels --test-stt Test speech-to-text functionality (default if no other mode specified) --debug-stt Debug speech-to-text (print transcripts without typing) - --stt-url Custom STT service URL (default: wss://api.preview.deepgram.com/v2/listen) + --stt-url Custom STT service URL (default: wss://api.deepgram.com/v2/listen) -h, --help Print help information -V, --version Print version information ``` @@ -116,7 +116,7 @@ The application provides sophisticated real-time transcript updates: ## About Deepgram Flux (Early Access) -- **Endpoint**: `wss://api.preview.deepgram.com/v2/listen` +- **Endpoint**: `wss://api.deepgram.com/v2/listen` - **What it is**: Flux is Deepgram's turn‑taking, low‑latency STT API designed for conversational experiences. - **Authentication**: Send an `Authorization` header. Common forms: - `Token ` (what this app uses) diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0b22632 --- /dev/null +++ b/flake.nix @@ -0,0 +1,22 @@ +{ + inputs = { + naersk.url = "github:nix-community/naersk/master"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, utils, naersk }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + naersk-lib = pkgs.callPackage naersk { }; + in + { + defaultPackage = naersk-lib.buildPackage ./.; + devShell = with pkgs; mkShell { + buildInputs = [ cargo rustc rustfmt rust-analyzer pre-commit rustPackages.clippy alsa-lib ]; + RUST_SRC_PATH = rustPlatform.rustLibSrc; + }; + } + ); +} diff --git a/src/stt_client.rs b/src/stt_client.rs index 57a1225..11b506b 100644 --- a/src/stt_client.rs +++ b/src/stt_client.rs @@ -9,7 +9,7 @@ use tokio_tungstenite::tungstenite::error::Error as WsError; use tokio_tungstenite::{connect_async, tungstenite::Message}; use tracing::{debug, error, info}; -pub const STT_URL: &str = "wss://api.preview.deepgram.com/v2/listen"; +pub const STT_URL: &str = "wss://api.deepgram.com/v2/listen"; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct WordInfo { From 1c54534d5386b78085d6eec4b0a6a85d71592519 Mon Sep 17 00:00:00 2001 From: Nik King Date: Tue, 7 Oct 2025 08:33:05 -0500 Subject: [PATCH 2/3] Use shebang with better compatibility --- run.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/run.sh b/run.sh index 3401a8a..767cb49 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Voice Keyboard Runner Script # This script runs the voice-keyboard with proper privilege handling @@ -11,8 +11,8 @@ # Check if we're already running as root if [ "$EUID" -eq 0 ]; then - echo "Error: Don't run this script as root. It will handle privileges automatically." - exit 1 + echo "Error: Don't run this script as root. It will handle privileges automatically." + exit 1 fi # Build the project first @@ -20,8 +20,8 @@ echo "Building voice-keyboard..." cargo build if [ $? -ne 0 ]; then - echo "Build failed!" - exit 1 + echo "Build failed!" + exit 1 fi # Run with sudo -E to preserve environment variables @@ -29,4 +29,5 @@ echo "Starting voice-keyboard with privilege dropping..." echo "Note: This will create a virtual keyboard as root, then drop privileges for audio access." echo "" -sudo -E ./target/debug/voice-keyboard "$@" \ No newline at end of file +sudo -E ./target/debug/voice-keyboard "$@" + From d897a145fddd208fb67d07bf58dd48470f910863 Mon Sep 17 00:00:00 2001 From: Nik King Date: Tue, 7 Oct 2025 08:34:35 -0500 Subject: [PATCH 3/3] Add spaces between turns Previously sentences were not separated with spaces. For example: "Hi.This is a test.No spaces between turns." Now: "Hi. This is a test. Spaces between turns." --- src/virtual_keyboard.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/virtual_keyboard.rs b/src/virtual_keyboard.rs index fdc4082..e1d0eb5 100644 --- a/src/virtual_keyboard.rs +++ b/src/virtual_keyboard.rs @@ -346,6 +346,9 @@ impl VirtualKeyboard { // Clear the current text tracking self.current_text.clear(); + // Add a space after the end of each turn + self.hardware.type_text(" ")?; + Ok(()) } @@ -475,10 +478,11 @@ mod tests { assert_eq!(kb.current_text, "hello"); assert!(!kb.hardware.enter_pressed); - // Finalize (should not press enter anymore) + // Finalize (should not press enter anymore but should add a space) kb.finalize_transcript().unwrap(); assert_eq!(kb.current_text, ""); assert!(!kb.hardware.enter_pressed); // Should remain false + assert_eq!(kb.hardware.typed_chars, ['h', 'e', 'l', 'l', 'o', ' ']); } #[test] @@ -610,12 +614,13 @@ mod tests { assert_eq!(kb.current_text, "hello world"); assert!(!kb.hardware.enter_pressed); - // Finalize - should not press ENTER key + // Finalize - should not press ENTER key but should add a space kb.finalize_transcript().unwrap(); assert_eq!(kb.current_text, ""); assert!(!kb.hardware.enter_pressed); // Should not have backspaced anything for the enter command assert_eq!(kb.hardware.backspace_count, 0); + assert_eq!(kb.hardware.typed_chars, ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', ' ']); } #[test] @@ -627,12 +632,13 @@ mod tests { assert_eq!(kb.current_text, "enter the room"); assert!(!kb.hardware.enter_pressed); - // Finalize - should not press ENTER key since "enter" is not the last word + // Finalize - should not press ENTER key since "enter" is not the last word but should add a space kb.finalize_transcript().unwrap(); assert_eq!(kb.current_text, ""); assert!(!kb.hardware.enter_pressed); // Should not have backspaced anything for the enter command assert_eq!(kb.hardware.backspace_count, 0); + assert_eq!(kb.hardware.typed_chars, ['e', 'n', 't', 'e', 'r', ' ', 't', 'h', 'e', ' ', 'r', 'o', 'o', 'm', ' ']); } #[test]