Skip to content
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

stdin support #69

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

stdin support #69

wants to merge 3 commits into from

Conversation

cianyyz
Copy link

@cianyyz cianyyz commented Nov 23, 2023

cat sound.wav | whisper-ctranslate2

Changed src/whisper-ctranslate2.py. Edits the check for no audio cli argument and no live transcribe.. If there is stdin data then a new temporary file is created and written to with the stdin data, then updates the audio ( cli argument ) to be the newly created temporary file.

The purpose of this is to allow foreign programs written in other languages to pipe in data to whisper-ctranslate2.

for audio_path in audio:
if verbose and len(audio) > 1:
print(f"\nFile: '{audio_path}'")

result = transcribe.inference(
Copy link
Collaborator

@jordimas jordimas Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please install black and run pip python -m black *.py to make sure that formatting is good and unnecessary additional spaces are removed if not needed.

@jordimas
Copy link
Collaborator

One of the improvements of the current code from an user perspective is that the outcome of the translation has the name of the temporary file. For example: tmp6ncx7s5c.txt. It's actually difficult for the user to understand that this cryptic name corresponds to the input provided to the pipe.

There are several solutions. One very simple solution is to save in the temporary directory a file always with the name "input.wav" (or similar) and then the outcome will be input.txt, input.srt, etc. It's not possible to know if wav will be always the right extension, but this is ignored when generating the transcriptions files.

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 this pull request may close these issues.

2 participants