diff options
| author | soryu <soryu@soryu.co> | 2025-12-22 01:00:12 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2025-12-23 14:47:18 +0000 |
| commit | aee2e4e784afd6d115fb5f7b40284c4efd2da966 (patch) | |
| tree | bcc6394f64913e7b740303c4cb03020c9a5c32da /tools | |
| parent | 75f2a72a06af6f722fce1bba1d1fc2f4c5e844df (diff) | |
| download | soryu-aee2e4e784afd6d115fb5f7b40284c4efd2da966.tar.gz soryu-aee2e4e784afd6d115fb5f7b40284c4efd2da966.zip | |
Use production endpoint for makima client
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/stt-client/src/main.rs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/tools/stt-client/src/main.rs b/tools/stt-client/src/main.rs index 73a9f8e..8b81b60 100644 --- a/tools/stt-client/src/main.rs +++ b/tools/stt-client/src/main.rs @@ -16,6 +16,9 @@ use tokio::sync::mpsc; use tokio_tungstenite::{connect_async, tungstenite::Message}; use url::Url; +const DEFAULT_REMOTE_URL: &str = "wss://api.makima.jp/api/v1/listen"; +const DEFAULT_LOCAL_URL: &str = "ws://localhost:8080/api/v1/listen"; + #[derive(Parser)] #[command(name = "stt-client")] #[command(about = "WebSocket client for testing the Makima STT streaming endpoint")] @@ -24,9 +27,13 @@ struct Args { #[arg(short, long)] file: PathBuf, - /// Server WebSocket URL - #[arg(short, long, default_value = "ws://localhost:8080/api/v1/listen")] - url: String, + /// Server WebSocket URL (overrides --local) + #[arg(short, long)] + url: Option<String>, + + /// Use local server (ws://localhost:8080) instead of remote API + #[arg(long, default_value = "false")] + local: bool, /// Chunk size in milliseconds for streaming #[arg(short, long, default_value = "100")] @@ -41,6 +48,18 @@ struct Args { show_progress: bool, } +impl Args { + fn get_url(&self) -> &str { + if let Some(ref url) = self.url { + url + } else if self.local { + DEFAULT_LOCAL_URL + } else { + DEFAULT_REMOTE_URL + } + } +} + #[derive(Serialize)] #[serde(tag = "type", rename_all = "camelCase")] enum ClientMessage { @@ -99,7 +118,7 @@ async fn main() -> Result<()> { ); // Connect to WebSocket - let url = Url::parse(&args.url)?; + let url = Url::parse(args.get_url())?; eprintln!("[INFO] Connecting to {}...", url); let (ws_stream, _) = connect_async(url.as_str()).await?; let (mut write, mut read) = ws_stream.split(); |
