深度语音推断更多音频文件和保存输出

2024-06-25 06:23:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经完成了Mozilla的deepspeech通用语音数据的培训,现在我可以获得单个音频.wav文件的输出。下面是我使用的命令。在

(deepspeech-venv) megha@megha-medion:~/Alu_Meg/DeepSpeech_Alug_Meg/DeepSpeech$ ./deepspeech my_exportdir/model.pb/output_graph.pb models/alphabet.txt myAudio_for_testing.wav

这里,我的音频_测试.wav是我用来获得以下输出的音频文件。在

^{pr2}$

先生,我们决定午餐时间在您的标准下进行

以下是我的几个问题

1)以上粗体句子是我的音频输出。我怎么能保存这个文件?在

2)我有大约2000个这样的音频文件。我怎样才能读1乘1得到输出?我试图用python编写一个脚本来读取我所有的.wav音频文件,但是由于deepspeech使用的是一些保存在虚拟环境中的源代码,我不知道如何在脚本中编写deepspeech命令。 你们能给我一些提示吗?这将是一个很大的帮助。在

谢谢:)

梅加


Tags: 文件数据命令脚本mozillavenv语音音频
2条回答

我找到了第一个问题的答案。我们可以将输出重定向到下面的某个文件。在

(deepspeech-venv) megha@megha-medion:~/Alu_Meg/DeepSpeech_Alug_Meg/DeepSpeech$ ./deepspeech my_exportdir/model.pb/output_graph.pb models/alphabet.txt myAudio_for_testing.wav > output_test.csv
TensorFlow: v1.6.0-9-g236f83e
DeepSpeech: v0.1.1-44-gd68fde8
Warning: reading entire model file into memory. Transform model file into an mmapped graph to reduce heap usage.
2018-06-29 15:22:50.275833: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

我刚刚添加了>;输出_测试.csv听我的命令。在

但第二个问题我还是想不通。在

对于我的第二个问题,我在客户端.py文件Deepspeech遇到多个文件,并将每一个成绩单保存在excel文件中,用相应的文件名作为索引值。在

> r =csv.reader(open('my_CSV_file.csv')) lines = list(r) pathToAudio =
> args.audio#sys.argv[3] audio_files = os.listdir(pathToAudio) for i in
> range(1,len(lines)):
>     for eachfile in audio_files :
>         if eachfile.endswith(".wav"):  
>             if(eachfile == lines[i][1]):
>               file_Path = pathToAudio + "/" + eachfile 
>                   print("File to be read is ",  file_Path)
>                   fs, audio = wav.read(file_Path)
>                   audio_length = len(audio) * ( 1 / 16000)
>                   assert fs == 16000, "Only 16000Hz input WAV files are supported for now!"
>                   print('Running inference.', file=sys.stderr)
>                   inference_start = timer()
>                   output = ds.stt(audio, fs)
>                   lines[i][2] = output                   
>                   writer = csv.writer(open('my_CSV_file', 'w'))
>                   writer.writerows(lines)
>                   print(output)
>                   inference_end = timer() - inference_start
>                   print('Inference took %0.3fs for %0.3fs audio file.' % (inference_end, audio_length), file=sys.stderr)

相关问题 更多 >