Comparing multiple whisper library outputs in python

So I had the brilliant idea of iterating a whisper model multiple times and comparing the results for best accuracy. For testing purposes I went with the base model, since it’s faster and may show better results since its WER is higher. Now the problem is, I have no clue how to compare those results (I want to compare the timestamps as well as the probability, and either output the mode or the one with the highest probability, whichever would give the better result).

import whisper
from whisper.utils import get_writer
from moviepy.editor import VideoFileClip
import os

def extract_audio_from_video(video_path, output_audio_path, volume_increase=2.0):
    """ Extracts audio from a video file, increases the volume, and saves it as an MP3 file. """
    # Load the video file
    video_clip = VideoFileClip(video_path)

    # Extract audio from the video clip
    audio_clip = video_clip.audio

    # Increase the volume of the audio clip
    audio_clip = audio_clip.volumex(volume_increase)

    # Write the extracted and volume-increased audio to an MP3 file
    audio_clip.write_audiofile(output_audio_path, codec='mp3')

    # Close the clips to free up resources
    video_clip.close()
    audio_clip.close()

# Path to the video file
video_path = (Assume a correct video path is added here)

# Path where the extracted audio will be saved
output_audio_path = "Video_Audio.mp3"

# Extract audio from video, increase the volume, and save as MP3
extract_audio_from_video(video_path, output_audio_path)


model = whisper.load_model('base')
audio = whisper.load_audio("/content/Video_Audio.mp3")
result1 = whisper.transcribe(model, audio, word_timestamps=True)
result2 = whisper.transcribe(model, audio, word_timestamps=True)
result3 = whisper.transcribe(model, audio, word_timestamps=True)
result4 = whisper.transcribe(model, audio, word_timestamps=True)
result5 = whisper.transcribe(model, audio, word_timestamps=True)

This outputted correctly. I tried many ways to compare the 5 and output the most repeated result (the mode if you’re familiar with mathematics) and failed miserably. Note that the mp3 file is one hour long, if it helps any.

New contributor

Amr Reda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật