Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,7 @@ def preprocess_text(text):
|
|
| 16 |
"""
|
| 17 |
Process the input text to prepare it for the model.
|
| 18 |
This could include tokenization, phoneme extraction, etc.
|
|
|
|
| 19 |
"""
|
| 20 |
d = cmudict.dict()
|
| 21 |
words = text.lower().split()
|
|
@@ -30,10 +31,17 @@ def preprocess_text(text):
|
|
| 30 |
|
| 31 |
# Flatten the list of phonemes
|
| 32 |
flattened_phonemes = [p for sublist in phonemes for p in sublist]
|
| 33 |
-
# Convert phonemes to numeric format for the model (customize this based on your model's input requirements)
|
| 34 |
-
numeric_input = np.array([hash(p) % 1000 for p in flattened_phonemes])
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
# Define function to generate sound
|
| 39 |
def generate_sfx(text):
|
|
@@ -43,9 +51,6 @@ def generate_sfx(text):
|
|
| 43 |
"""
|
| 44 |
input_data = preprocess_text(text)
|
| 45 |
|
| 46 |
-
# Add batch dimension
|
| 47 |
-
input_data = np.expand_dims(input_data, axis=0)
|
| 48 |
-
|
| 49 |
# Generate prediction
|
| 50 |
prediction = model.predict(input_data)
|
| 51 |
|
|
|
|
| 16 |
"""
|
| 17 |
Process the input text to prepare it for the model.
|
| 18 |
This could include tokenization, phoneme extraction, etc.
|
| 19 |
+
The model expects input of shape (batch_size, sequence_length, 13).
|
| 20 |
"""
|
| 21 |
d = cmudict.dict()
|
| 22 |
words = text.lower().split()
|
|
|
|
| 31 |
|
| 32 |
# Flatten the list of phonemes
|
| 33 |
flattened_phonemes = [p for sublist in phonemes for p in sublist]
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
# Create dummy 13-feature vectors for each phoneme (you need to implement your own feature extraction)
|
| 36 |
+
# Here we create a placeholder with 13 features for each phoneme.
|
| 37 |
+
num_features = 13
|
| 38 |
+
sequence_length = len(flattened_phonemes)
|
| 39 |
+
input_data = np.random.rand(sequence_length, num_features) # Placeholder, replace with actual feature extraction
|
| 40 |
+
|
| 41 |
+
# Add batch dimension
|
| 42 |
+
input_data = np.expand_dims(input_data, axis=0) # Shape (1, sequence_length, 13)
|
| 43 |
+
|
| 44 |
+
return input_data
|
| 45 |
|
| 46 |
# Define function to generate sound
|
| 47 |
def generate_sfx(text):
|
|
|
|
| 51 |
"""
|
| 52 |
input_data = preprocess_text(text)
|
| 53 |
|
|
|
|
|
|
|
|
|
|
| 54 |
# Generate prediction
|
| 55 |
prediction = model.predict(input_data)
|
| 56 |
|