-
Notifications
You must be signed in to change notification settings - Fork 563
feat: Add Azure OpenAI Realtime API support for transcription (STT) #4476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3fa94f5
ed609d3
de7ff8a
00219bc
4af34b1
556665e
16ea987
59e8c92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,10 +44,14 @@ async fn ensure_parent_dirs(path: &Path) -> CliResult<()> { | |
| Ok(()) | ||
| } | ||
|
|
||
| async fn write_bytes_to(output: Option<&Path>, bytes: Vec<u8>) -> CliResult<()> { | ||
| async fn write_bytes_to(output: Option<&Path>, bytes: Vec<u8>, add_newline: bool) -> CliResult<()> { | ||
| if let Some(path) = output { | ||
| ensure_parent_dirs(path).await?; | ||
| tokio::fs::write(path, bytes) | ||
| let mut data = bytes; | ||
| if add_newline { | ||
| data.push(b'\n'); | ||
| } | ||
| tokio::fs::write(path, data) | ||
| .await | ||
| .map_err(|e| CliError::operation_failed("write output", e.to_string()))?; | ||
| return Ok(()); | ||
|
|
@@ -56,14 +60,17 @@ async fn write_bytes_to(output: Option<&Path>, bytes: Vec<u8>) -> CliResult<()> | |
| std::io::stdout() | ||
| .write_all(&bytes) | ||
| .map_err(|e| CliError::operation_failed("write output", e.to_string()))?; | ||
| std::io::stdout() | ||
| .write_all(b"\n") | ||
| .map_err(|e| CliError::operation_failed("write output", e.to_string()))?; | ||
| if add_newline { | ||
| std::io::stdout() | ||
| .write_all(b"\n") | ||
| .map_err(|e| CliError::operation_failed("write output", e.to_string()))?; | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub async fn write_text(output: Option<&Path>, text: String) -> CliResult<()> { | ||
| write_bytes_to(output, (text + "\n").into_bytes()).await | ||
| // Text content; add single trailing newline for POSIX compliance | ||
| write_bytes_to(output, text.into_bytes(), true).await | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double newline when writing text to stdoutLow Severity
Additional Locations (1) |
||
|
|
||
| pub async fn write_json(output: Option<&Path>, value: &impl serde::Serialize) -> CliResult<()> { | ||
|
|
@@ -74,7 +81,8 @@ pub async fn write_json(output: Option<&Path>, value: &impl serde::Serialize) -> | |
| } | ||
| .map_err(|e| CliError::operation_failed("serialize response", e.to_string()))?; | ||
|
|
||
| write_bytes_to(output, bytes).await | ||
| // JSON output needs trailing newline for POSIX compliance | ||
| write_bytes_to(output, bytes, true).await | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File output missing trailing newline in write helper
Low Severity
write_bytes_toignores theadd_newlineparameter when writing to a file (theSome(path)branch on line 18-23 returns early without checkingadd_newline). The old code explicitly appended"\n"when writing text to a file viatokio::fs::write(path, transcript + "\n"). Now,write_textandwrite_jsonboth passadd_newline: true, but that flag only takes effect for the stdout path. Output files produced via--outputwill be missing their trailing newline, breaking POSIX text file conventions.