Fix parselmouth commands: use 'Change pitch' + 'Change formants' instead of 'Change gender'
Browse files- app_simple.py +6 -9
app_simple.py
CHANGED
|
@@ -51,24 +51,21 @@ def convert_voice_simple(
|
|
| 51 |
# Convert to parselmouth Sound
|
| 52 |
sound = parselmouth.Sound(y, sampling_frequency=sr)
|
| 53 |
|
| 54 |
-
# 1. Pitch shift using PSOLA
|
| 55 |
if pitch_shift != 0:
|
| 56 |
-
# Convert semitones to ratio
|
| 57 |
pitch_ratio = 2 ** (pitch_shift / 12.0)
|
| 58 |
-
#
|
| 59 |
-
sound = call(sound, "Change
|
| 60 |
|
| 61 |
-
# 2. Formant shift
|
| 62 |
if formant_shift != 0:
|
| 63 |
formant_ratio = 2 ** (formant_shift / 12.0)
|
| 64 |
-
# Change formants
|
| 65 |
-
sound = call(sound, "Change
|
| 66 |
|
| 67 |
# 3. Add breathiness (mix with noise)
|
| 68 |
if breathiness > 0:
|
| 69 |
-
# Generate breath noise
|
| 70 |
noise = np.random.normal(0, breathiness * 0.1, len(sound.values[0]))
|
| 71 |
-
# Apply noise mainly to unvoiced segments (simple approach)
|
| 72 |
sound.values[0] = sound.values[0] * (1 - breathiness) + noise * breathiness
|
| 73 |
|
| 74 |
# Get result
|
|
|
|
| 51 |
# Convert to parselmouth Sound
|
| 52 |
sound = parselmouth.Sound(y, sampling_frequency=sr)
|
| 53 |
|
| 54 |
+
# 1. Pitch shift using PSOLA (Change pitch command)
|
| 55 |
if pitch_shift != 0:
|
|
|
|
| 56 |
pitch_ratio = 2 ** (pitch_shift / 12.0)
|
| 57 |
+
# Change pitch: pitch_ratio, time_step, min_pitch, max_pitch
|
| 58 |
+
sound = call(sound, "Change pitch", pitch_ratio, 0.01, 50, 500)
|
| 59 |
|
| 60 |
+
# 2. Formant shift (Change formants command)
|
| 61 |
if formant_shift != 0:
|
| 62 |
formant_ratio = 2 ** (formant_shift / 12.0)
|
| 63 |
+
# Change formants: formant_ratio, new_pitch_median
|
| 64 |
+
sound = call(sound, "Change formants", formant_ratio, 1.0)
|
| 65 |
|
| 66 |
# 3. Add breathiness (mix with noise)
|
| 67 |
if breathiness > 0:
|
|
|
|
| 68 |
noise = np.random.normal(0, breathiness * 0.1, len(sound.values[0]))
|
|
|
|
| 69 |
sound.values[0] = sound.values[0] * (1 - breathiness) + noise * breathiness
|
| 70 |
|
| 71 |
# Get result
|