I am implementing multithreading on whisper Api. I getting this error RuntimeError: The size of tensor a (6) must match the size of tensor b (3) at non-singleton dimension 3
Can anyone help me please. I am new to this I searched but didn't get anything.
from concurrent.futures import ThreadPoolExecutor
import numpy as np
def transcribe_chunk(model, file):
# print(file)
result = model.transcribe(file)
print(result)
return result["text"]
def process_audio(filename):
transcript = open("transcript.txt", "w+")
myaudio = AudioSegment.from_file(filename)
chunks_length_ms = 600000
chunks = make_chunks(myaudio, chunks_length_ms)
print(chunks)
model = whisper.load_model("small")
with ThreadPoolExecutor() as executor:
futures = []
for i, chunk in enumerate(chunks):
chunk_array = np.array(chunk.get_array_of_samples())
audio = chunk_array.astype(np.float32)/32768.0
print("audio", audio)
future = executor.submit(transcribe_chunk, model, audio)
futures.append(future)
for future in futures:
result = future.result()
transcript.write(result + ".\n")
process_audio("user_story.mp3")