applying the model on a set of audio files

(badis rachrache) #1

i have tried the pre-trained model on a single file, but i need to try it on a set of audio files an save the results (text of each audio file)
in exel file …

need some hints to start with


Mail]( for Windows 10

(Gr8nishan) #2

This is a sample python script that i wrote to read wav files from a folder and write the output in a text file

You can run the script in the below way where tmp is the folder where your audio files are

Hope it helps :slight_smile:
python models2/output_graph.pb models2/alphabet.txt tmp/

 from deepspeech.model import Model
    import as wav
    import sys
    import os as os

    ds = Model(sys.argv[1], 26, 9, sys.argv[2], 500)

    pathToAudio = sys.argv[3]
    audio_files = os.listdir(pathToAudio)
    for eachfile in audio_files :
        if eachfile.endswith(".wav"):
            file_Path = pathToAudio + eachfile
            print("File to be read is ",  file_Path)    
            fs, audio =
            processed_data = ds.stt(audio, fs)
            print("Processed Data : " , processed_data)
            with open('output.txt', 'a') as f:
                f.write("\r\n")`Preformatted text`