summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/stt-client/src/main.rs27
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();