alphacep/vosk-api

Trying to use portuguese transcript

gabrielroses15 opened this issue · 2 comments

if you want, this is the code in python:
from vosk import Model, KaldiRecognizer
import os
import wave

Caminho do arquivo de áudio que você deseja transcrever

audio_file_path = r"C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/audio.mp4"

Inicializando o modelo e o reconhecedor

model = Model("C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/modeloptbr")
rec = KaldiRecognizer(model, 16000)

Abrir o arquivo de áudio

with wave.open(audio_file_path, 'rb') as wf:
# Ler o conteúdo do arquivo em pedaços (chunks)
chunk_size = 4000
while True:
data = wf.readframes(chunk_size)
if not data:
break # Break the loop if no more data is available

    # Convertendo áudio em texto
    if rec.AcceptWaveform(data):
        result = rec.Result()
        print(result)

Salvando o resultado em um arquivo

output_file_path = r"C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/output.txt"
with open(output_file_path, 'a', encoding='utf-8') as output_file:
output_file.write(result + '\n')

and this is the log (error):
LOG (VoskAPI:ReadDataFiles():model.cc:213) Decoding params beam=10 max-active=7000 lattice-beam=6
LOG (VoskAPI:ReadDataFiles():model.cc:216) Silence phones 1:2:3:4:5:6:7:8:9:10
LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 0 orphan nodes.
LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 0 orphan components.
LOG (VoskAPI:ReadDataFiles():model.cc:248) Loading i-vector extractor from C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/modeloptbr/ivector/final.ie
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:204) Done.
LOG (VoskAPI:ReadDataFiles():model.cc:279) Loading HCLG from C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/modeloptbr/graph/HCLG.fst
LOG (VoskAPI:ReadDataFiles():model.cc:297) Loading words from C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/modeloptbr/graph/words.txt
LOG (VoskAPI:ReadDataFiles():model.cc:308) Loading winfo C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/modeloptbr/graph/phones/word_boundary.int
LOG (VoskAPI:ReadDataFiles():model.cc:315) Loading subtract G.fst model from C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/modeloptbr/rescore/G.fst
LOG (VoskAPI:ReadDataFiles():model.cc:317) Loading CARPA model from C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/modeloptbr/rescore/G.carpa
ERROR (VoskAPI:ReadInternal():const-arpa-lm.cc:610) ConstArpaLm section reading failed.
Traceback (most recent call last):
File "c:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/teste2.py", line 9, in
model = Model("C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/modeloptbr")
File "C:\Users\gabriel.rosa\Desktop\MailSenderBot-master\GPT testes\deepspeech\lib\site-packages\vosk_init_.py", line 57, in init
raise Exception("Failed to create a model")
Exception: Failed to create a model

I see you talking about other issue, so i download other model ("https://alphacephei.com/vosk/models/vosk-model-pt-fb-v0.1.1-pruned.zip")
Traceback (most recent call last):
File "c:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/teste2.py", line 40, in
model = Model("C:/Users/gabriel.rosa/Desktop/MailSenderBot-master/GPT testes/modeloptbr")
File "C:\Users\gabriel.rosa\Desktop\MailSenderBot-master\GPT testes\deepspeech\lib\site-packages\vosk_init_.py", line 57, in init
raise Exception("Failed to create a model")
Exception: Failed to create a model

its worked, was the audio (i was trying .mp4)
Thx