Closed a-doering closed 3 years ago
Do you provide audio_wav_path
?
Yes, I provide the path to a .wav file. The file is sampled correctly and can be accessed. The script above worked for printing to terminal, but with these added changes I was unable to write to file. I managed to make it work another way (see below) but am still very interested in what went wrong previously. If you do not have an idea, I think this issue can be closed. Thanks for the answer :)
import sys
# My path setup, imports
w2l_bin = '/root/wav2letter/build/inference/inference/examples/interactive_streaming_asr_example'
2l_process = Popen(['{} --input_files_base_path={}'.format(w2l_bin, model_path)],
stdin=PIPE, stdout=PIPE, stderr=PIPE,
shell=True)
with file('path/to/file.txt') as f:
sys.stdout = f
# Now all the print statements go to file
# and I can use the inference code for printing to terminal
# that is now redirected to file.
w2l_process.stdin.write("input={}\n".format(audio_wav_path).encode())
w2l_process.stdin.flush()
# Rest of the process as before
So in the code above (original code) you cannot open file and instead of print(output)
do f.write(output)
?
PS. Your posted solution looks good to me. Probably you can directly set it to file with configuring the Popen stdout.
In the original code from the documentation I cannot write to file (no errors, I just don't know where it writes to). The one with f.write(output) works for me.
From this example https://github.com/facebookresearch/wav2letter/wiki/Inference-Run-Examples#how-we-can-i-use-this-from-python it should not write into file, it will write into standard output.
Question
I am trying to follow the documentation for interactive streaming asr with python to write output to a file. I can have the output printed to the terminal without problems, but when writing to a file, it doesn't kill the process (when I manually kill the process with ctrl + c it does save the output). It seems to be stuck in the line
output = w2l_process.stdout.readline()
according to the message when killing it. How can I kill the process and save the output to file?Setup
I am running this in the inference docker container, python version = 3.6.12 . The model and audio files are also in the container.
Code
Terminal Output
Terminal output with ctrl + c kill message.
Thanks in advance for any hints and thanks for providing this repo.