jianfch / stable-ts

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

Adding regrouping exceptions? #210

Closed Max160 closed 1 year ago

Max160 commented 1 year ago

Hi,

Thank you very much for your work, this is very useful!

In this topic, I have noticed that one user indicated adding exceptions for the regrouping:

Thanks. The following works wonderfully for me:

result = modelw.transcribe(conv_audio, regroup='sp=.* /。/?/?/./!/!')

I have also added some regrouping exceptions:

abbre = ('Dr.', 'Mr.', 'Mrs.', 'Ms.', 'vs.', 'Prof.')

[...]

I would like to add exceptions myself, but I have not figured out yet how to do it. Is it possible?

Thanks for your help!

jianfch commented 1 year ago

You can try it with lock():

result = model.transcribe(..., regroup='l=+Dr./Mr./Mrs./Ms./vs./Prof._da')
# or
result = model.transcribe(..., regroup=False)
result.lock(endswith=['Dr.', 'Mr.', 'Mrs.', 'Ms.', 'vs.', 'Prof.'])
result.regroup()
Max160 commented 1 year ago

Thank you very much @jianfch ! For your answer, and also adding lock() to commit 384fc3c

If I understand correctly, this line in the commit:

-updated regroup() to parse [regroup_algo] into dict so that if no value is provided, the argument will be default value instead of None

means that we don't have to put the default regrouping algorithm as argument anymore. Great!

Also, being able to use align() is great to be able to test different regrouping algorithms on SRTs that have been generated a long time ago (just need to extract the pure text from SRTs, without timestamps).

jianfch commented 1 year ago

-updated regroup() to parse [regroup_algo] into dict so that if no value is provided, the argument will be default value instead of None

It means that you use +++1, it will directly assign the 4th argument the value 1 instead of passing in 3 None then a 1.

Max160 commented 1 year ago

Thank you so much so much @jianfch ! The lock() function works like a charm for this!