bootphon / phonemizer

Simple text to phones converter for multiple languages
https://bootphon.github.io/phonemizer/
GNU General Public License v3.0
1.18k stars 165 forks source link

Version 3.0 is slower than version 2.2.2 #88

Closed donand closed 2 years ago

donand commented 2 years ago

Describe the bug As I read in the release 3.0, now the library should be much faster with the speak backend. I compared the times between version 2.2.2 and 3.0 and the version 2.2.2 is faster.

Release 3.0: https://github.com/bootphon/phonemizer/releases/tag/v3.0

Phonemizer version Old

Python 3.6.13 :: Anaconda, Inc.
phonemizer-2.2.2
available backends: espeak-ng-1.50, segments-2.2.0
uninstalled backends: espeak-mbrola, festival

New

Python 3.9.5
phonemizer-3.0
available backends: espeak-ng-1.50, segments-2.2.0
uninstalled backends: espeak-mbrola, festival

System

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

To reproduce

from phonemizer import phonemize
import time

start = time.time()
for i in range(100):
    phonemize("Some random sentence to transcribe.", language='en-us', backend='espeak', preserve_punctuation=True, with_stress=True, language_switch='remove-flags')

print(f'Time: {time.time() - start:.2f} s')
Version 2.2.2 -> 8.2 seconds
Version 3.0 -> 12.8 seconds

Expected behavior Version 3.0 should be faster than version 2.2.2

mmmaat commented 2 years ago

Hi Andrea, this is the expected behavior, see https://github.com/bootphon/phonemizer#python-usage (or the docstring in phonemize(). Do the same with that, you should see a difference :)

from phonemizer import phonemize
import time

text = ["Some random sentence to transcribe."] * 100
start = time.time()
phonemize(text, language='en-us', backend='espeak', preserve_punctuation=True, with_stress=True, language_switch='remove-flags')
print(f'Time: {time.time() - start:.2f} s')