Add -o/--output flag to write transcription text to a file#113
Open
tim-janik wants to merge 1 commit into
Open
Add -o/--output flag to write transcription text to a file#113tim-janik wants to merge 1 commit into
tim-janik wants to merge 1 commit into
Conversation
When -o <path> is given, the CLI writes only the transcribed text (no metadata, no timestamps, no timings) to that file. Stdout is unchanged. In batch mode each utterance's text goes on its own line. examples/cli/main.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
There was a problem hiding this comment.
Pull request overview
Adds a new -o/--output option to the example CLI (transcribe-cli) to optionally write the transcription text to a user-specified file, aimed at making scripting/automation easier while keeping existing stdout behavior.
Changes:
- Introduces
cli_args::output_pathand parses-o/--output PATH. - Updates
--help/usage text to document the new flag. - Adds a helper to write transcription text to a file and calls it from batch and single-file execution paths.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
204
to
208
| bool quiet = false; | ||
| bool list_devices = false; // --list-devices: print devices and exit | ||
| bool batch_jsonl = false; // --batch-jsonl: output JSONL | ||
| std::string output_path; // -o: write raw text here | ||
| int repeat = 1; |
Comment on lines
284
to
287
| " -q, --quiet suppress library log output\n" | ||
| " -r, --repeat N run N times per file (benchmark)\n" | ||
| " -o, --output PATH write transcribed text to PATH (stdout unchanged)\n" | ||
| " --threads N CPU threads (default: all cores)\n" |
Comment on lines
+701
to
+711
| static void write_output_file(const std::string & path, const char * text) { | ||
| if (path.empty() || text == nullptr || text[0] == '\0') { | ||
| return; | ||
| } | ||
| std::ofstream fout(path, std::ios::binary | std::ios::app); | ||
| if (!fout) { | ||
| std::fprintf(stderr, "error: cannot open %s for writing\n", path.c_str()); | ||
| } else { | ||
| fout << text << '\n'; | ||
| } | ||
| } |
Comment on lines
+705
to
+709
| std::ofstream fout(path, std::ios::binary | std::ios::app); | ||
| if (!fout) { | ||
| std::fprintf(stderr, "error: cannot open %s for writing\n", path.c_str()); | ||
| } else { | ||
| fout << text << '\n'; |
Contributor
|
Thanks I'll take a look when I've got a good chance and merge |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
I wanted a clean way to get transcribed text right after compiling the project for scripting purposes.
The simplest way I saw was to write it into a separate file, so I added a --output option, when -o is given, the CLI writes only the transcribed text (no metadata, no timestamps, no timings) to the given file.
Feel free to merge if you consider this the right approach.