Skip to content

Can't output to file descriptor #3048

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

Closed
danielzgtg opened this issue Apr 14, 2025 · 1 comment · Fixed by #3050
Closed

Can't output to file descriptor #3048

danielzgtg opened this issue Apr 14, 2025 · 1 comment · Fixed by #3050

Comments

@danielzgtg
Copy link
Contributor

I would like whisper-cli to have the generality of being able to output to a file descriptor. We can already input from a fd using /dev/fd/3, but it doesn't work with -of /dev/fd/4. Accepting an output file descriptor could allow me the flexibility of using sockets and pipes.

Here is an simplified example of the current error:

$ exec 3<path/to/wav
$ exec 4>/path/to/vtt
$ ~/path/to/whisper-cli -l auto -ovtt -m path/to/model /dev/fd/3 -of /dev/fd/4
[...]
whisper_model_load: [...]
[...]

main: processing '/dev/fd/3' [...]

[00:00:00.000 --> 00:00:10.000]   [...]
[...]

output_vtt: failed to open '/dev/fd/4.vtt' for writing

whisper_print_timings: [...]
@danielzgtg
Copy link
Contributor Author

Seems like fd input won't work unless it's stdin. Despite bash overloading /dev, I decided that mimicking the existing - stdin logic would avoid nix-specific behavior. The updated command would be ~/path/to/whisper-cli -l auto -ovtt -m path/to/model - <&3 -of - >&4, where -of - is optional in this example.

danielzgtg added a commit to danielzgtg/whisper.cpp that referenced this issue Apr 15, 2025
This changes examples/cli/cli.cpp to be like
examples/common-whisper.cpp. "-of -" can be specified (or this can be
inferred from "-" as the input file) to output to stdout. This is useful
for piping to other applications.

Closes ggml-org#3048
danielzgtg added a commit to danielzgtg/whisper.cpp that referenced this issue Apr 15, 2025
This changes examples/cli/cli.cpp to be like
examples/common-whisper.cpp. "-of -" can be specified (or this can be
inferred from "-" as the input file) to output to stdout. This is useful
for piping to other applications.

Closes ggml-org#3048
danielzgtg added a commit to danielzgtg/whisper.cpp that referenced this issue Apr 15, 2025
This changes examples/cli/cli.cpp to be like
examples/common-whisper.cpp. "-of -" can be specified (or this can be
inferred from "-" as the input file) to output to stdout. This is useful
for piping to other applications.

Closes ggml-org#3048
danielzgtg added a commit to danielzgtg/whisper.cpp that referenced this issue Apr 15, 2025
This changes examples/cli/cli.cpp to be like
examples/common-whisper.cpp. "-of -" can be specified (or this can be
inferred from "-" as the input file) to output to stdout. This is useful
for piping to other applications.

Closes ggml-org#3048
danielzgtg added a commit to danielzgtg/whisper.cpp that referenced this issue Apr 15, 2025
This changes examples/cli/cli.cpp to be like
examples/common-whisper.cpp. "-of -" can be specified (or this can be
inferred from "-" as the input file) to output to stdout. This is useful
for piping to other applications.

Closes ggml-org#3048
danielzgtg added a commit to danielzgtg/whisper.cpp that referenced this issue May 2, 2025
This changes examples/cli/cli.cpp to be like
examples/common-whisper.cpp. "-of -" can be specified (or this can be
inferred from "-" as the input file) to output to stdout. This is useful
for piping to other applications.

Log fname_out consistently when not stdout
- Terminals have stdout=stderr, so remove the message before
  successful output to ease copying
- Don't affect actual error messages
- Move opening the ofstream into the factory, fixing missing
  open and/or error messages in output_score/output_wts
- Fix struct naming convention

Closes ggml-org#3048
danielzgtg added a commit to danielzgtg/whisper.cpp that referenced this issue May 4, 2025
This changes examples/cli/cli.cpp to be like
examples/common-whisper.cpp. "-of -" can be specified (or this can be
inferred from "-" as the input file) to output to stdout. This is useful
for piping to other applications.

Log fname_out consistently when not stdout
- Terminals have stdout=stderr, so remove the message before
  successful output to ease copying
- Don't affect actual error messages
- Move opening the ofstream into the factory, fixing missing
  open and/or error messages in output_score/output_wts
- Fix struct naming convention

Closes ggml-org#3048
danbev pushed a commit that referenced this issue May 5, 2025
This changes examples/cli/cli.cpp to be like
examples/common-whisper.cpp. "-of -" can be specified (or this can be
inferred from "-" as the input file) to output to stdout. This is useful
for piping to other applications.

Log fname_out consistently when not stdout
- Terminals have stdout=stderr, so remove the message before
  successful output to ease copying
- Don't affect actual error messages
- Move opening the ofstream into the factory, fixing missing
  open and/or error messages in output_score/output_wts
- Fix struct naming convention

Closes #3048
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant