ford442 commited on
Commit
97a0fb8
·
verified ·
1 Parent(s): 5ce404d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -39,12 +39,25 @@ TTS_MODEL_PATH = "path/to/your/espnet/kan-bayashi_ljspeech_vits" # Replace with
39
  TTS_CONFIG_PATH = os.path.join(TTS_MODEL_PATH, "config.yaml") # Replace with your config.yaml
40
  TTS_VOCAB_PATH = os.path.join(TTS_MODEL_PATH, "train.json") # Replace with your train.json
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  tts = Text2Speech(
43
  TTS_MODEL_PATH,
44
  TTS_CONFIG_PATH,
45
  TTS_VOCAB_PATH,
46
  device="cuda" if torch.cuda.is_available() else "cpu",
47
- # You can customize the speed and other parameters here if needed
48
  )
49
  fastspeech_config = get_fastspeech_config(TTS_CONFIG_PATH)
50
 
 
39
  TTS_CONFIG_PATH = os.path.join(TTS_MODEL_PATH, "config.yaml") # Replace with your config.yaml
40
  TTS_VOCAB_PATH = os.path.join(TTS_MODEL_PATH, "train.json") # Replace with your train.json
41
 
42
+ # Load the configuration using yaml
43
+ with open(TTS_CONFIG_PATH, "r") as f:
44
+ config = yaml.safe_load(f)
45
+
46
+ # Correctly handle the threshold parameter
47
+ threshold = config.get("threshold", 0.5) # Get threshold, default to 0.5 if not found
48
+ if isinstance(threshold, str): # Check if it's a string
49
+ try:
50
+ threshold = float(threshold) # Try converting to float
51
+ except ValueError:
52
+ threshold = 0.5 # If conversion fails, use a default value
53
+
54
+
55
  tts = Text2Speech(
56
  TTS_MODEL_PATH,
57
  TTS_CONFIG_PATH,
58
  TTS_VOCAB_PATH,
59
  device="cuda" if torch.cuda.is_available() else "cpu",
60
+ threshold=threshold # Pass the corrected threshold value
61
  )
62
  fastspeech_config = get_fastspeech_config(TTS_CONFIG_PATH)
63