Skip to content

Commit

Permalink
F5-TTS final updates
Browse files Browse the repository at this point in the history
  • Loading branch information
erew123 authored Nov 5, 2024
1 parent 75a3b68 commit 2c2c31e
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions system/tts_engines/f5tts/model_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
# In this section you will import any imports that your specific TTS Engine will use. You will provide any
# start-up errors for those bits, as if you were starting up a normal Python script. Note the logging.disable
# a few lines up from here, you may want to # that out while debugging!
from vocos import Vocos
import soundfile as sf
import tempfile
from pydub import AudioSegment, silence
Expand All @@ -39,19 +38,33 @@

def install_and_restart():
try:
print("##########################################")
print("F5-TTS not found. Attempting to install...")
print("##########################################")
print("#################################################################")
print("Installing required packages for F5-TTS... This may take a while.")
print("################################################################")

# Install vocos first
print("Installing vocos...")
subprocess.check_call([
sys.executable,
"-m",
"pip",
"install",
"vocos"
])

# Then install F5-TTS
print("Installing F5-TTS...")
subprocess.check_call([
sys.executable,
"-m",
"pip",
"install",
"git+https://github.com/SWivid/F5-TTS.git"
])
print("########################################################")
print("F5-TTS installed successfully! Restarting application...")
print("########################################################")

print("##############################################################")
print("All packages installed successfully! Restarting application...")
print("##############################################################")

# Get the current script's path
script_path = sys.argv[0]
Expand All @@ -61,16 +74,17 @@ def install_and_restart():

except subprocess.CalledProcessError as e:
print("########################################################")
print(f"Failed to install F5-TTS: {str(e)}")
print(f"Failed to install required packages: {str(e)}")
print("########################################################")
raise ImportError("Could not install required package F5-TTS")
raise ImportError("Could not install required packages")

try:
from f5_tts.model import CFM, DiT
from f5_tts.model.utils import (
get_tokenizer,
convert_char_to_pinyin,
)
from vocos import Vocos
except ImportError:
install_and_restart()

Expand Down

0 comments on commit 2c2c31e

Please sign in to comment.