jianfch / stable-ts

Transcription, forced alignment, and audio indexing with OpenAI's Whisper
MIT License
1.59k stars 177 forks source link

Attribute error in alignment #357

Closed xinzuan closed 6 months ago

xinzuan commented 6 months ago

After updating the stable ts package, I encountered an error when testing it with an audio file. Here is the error message:

line 449, in is_new_better
    speech0 = speech_percentage(w0, m0, o0).round(decimals=1)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'round'

I add additional checking to temporary fix the issues:

    def is_new_better(w0, m0, o0, w1, m1, o1):
        speech0 =  speech_percentage(w0, m0, o0) 
        speech1 = speech_percentage(w1, m1, o1)

        if isinstance(speech0, float):  
            speech0 = speech0.round(decimals=1)
        if isinstance(speech1, float):
            speech1 = speech1.round(decimals=1)

        w0p, w1p = w0['probability'], w1['probability']
        return ((w1p**0.75 - w0p**0.75) < 0.35 and speech0 >= speech1) or w0p >= w1p