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

Thanks

Mail](https://go.microsoft.com/fwlink/?LinkId=550986) 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 SnToTxt.py models2/output_graph.pb models2/alphabet.txt tmp/

 from deepspeech.model import Model
    import scipy.io.wavfile 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 = wav.read(file_Path)
            processed_data = ds.stt(audio, fs)
            print("Processed Data : " , processed_data)
            with open('output.txt', 'a') as f:
                f.write(processed_data)
                f.write("\r\n") 
                f.write("\r\n")`Preformatted text`

(Megha ) #3

In the above solution, from deepspeech.model import Model is used. This is using the pretrained model provided by Deepspeech right?
How can I use the model I trained to produce transcripts for set of audio files?


(Gr8nishan) #4

Replace the model created by you in the model folder… hope it helps