uzagi commited on
Commit
e90c6d1
·
verified ·
1 Parent(s): a2e6230

Update phoneme.py

Browse files
Files changed (1) hide show
  1. phoneme.py +0 -24
phoneme.py CHANGED
@@ -5,17 +5,6 @@ from transformers import AutoProcessor, AutoModelForCTC, Wav2Vec2PhonemeCTCToken
5
  import librosa
6
  from itertools import groupby
7
  from datasets import load_dataset
8
- from phonemizer import phonemize
9
- from phonemizer.backend.espeak.wrapper import EspeakWrapper
10
-
11
- # PHONEMIZER_ESPEAK_LIBRARY="c:\Program Files\eSpeak NG\libespeak-ng.dll"
12
- # PHONEMIZER_ESPEAK_PATH="c:\Program Files\eSpeak NG"
13
- # ESPEAK_PATH = os.getenv("PHONEMIZER_ESPEAK_LIBRARY")
14
- # if ESPEAK_PATH is not None:
15
- # EspeakWrapper.set_library(ESPEAK_PATH)
16
- # print(f"Loaded environment variables PHONEMIZER_ESPEAK_LIBRARY: {ESPEAK_PATH}")
17
- # print(f"Using espeak library: {EspeakWrapper.library_path}")
18
-
19
 
20
  # Load the model and processor
21
  # checkpoint = "bookbot/wav2vec2-ljspeech-gruut"
@@ -59,16 +48,6 @@ def text_to_phonemes(text: str) -> str:
59
  return phonemes
60
 
61
 
62
- def text_to_phonemes_2(text: str) -> str:
63
- s_time = time.time()
64
- """Convert text to phonemes using phonemizer."""
65
- phonemes = phonemize(text, language="en-us", backend="espeak", strip=True)
66
- # phonemes = tokenizer.phonemize(text)
67
- e_time = time.time()
68
- print(f"Execution time of text_to_phonemes_2: {e_time - s_time:.6f} seconds")
69
- return phonemes
70
-
71
-
72
  def separate_characters(input_string):
73
  no_spaces = input_string.replace(" ", "")
74
  spaced_string = " ".join(no_spaces)
@@ -134,10 +113,7 @@ def test_sound():
134
  # Call the phoneme prediction function
135
  predicted_phonemes = predict_phonemes(audio_array)
136
  adjusted_phonemes = adjust_phonemes(predicted_phonemes)
137
-
138
- # expected_phonemes_2 = text_to_phonemes_2(expected_transcript)
139
  print(f"Expected Phonemes: {expected_phonemes}")
140
- # print(f"Expected Phonemes 2: {expected_phonemes_2}")
141
  print(f"Predicted Phonemes: {predicted_phonemes}")
142
  print(f"Adjusted Phonemes: {adjusted_phonemes}")
143
 
 
5
  import librosa
6
  from itertools import groupby
7
  from datasets import load_dataset
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  # Load the model and processor
10
  # checkpoint = "bookbot/wav2vec2-ljspeech-gruut"
 
48
  return phonemes
49
 
50
 
 
 
 
 
 
 
 
 
 
 
51
  def separate_characters(input_string):
52
  no_spaces = input_string.replace(" ", "")
53
  spaced_string = " ".join(no_spaces)
 
113
  # Call the phoneme prediction function
114
  predicted_phonemes = predict_phonemes(audio_array)
115
  adjusted_phonemes = adjust_phonemes(predicted_phonemes)
 
 
116
  print(f"Expected Phonemes: {expected_phonemes}")
 
117
  print(f"Predicted Phonemes: {predicted_phonemes}")
118
  print(f"Adjusted Phonemes: {adjusted_phonemes}")
119