Spaces:
Running
on
Zero
Running
on
Zero
刘悦
commited on
Commit
•
cf43100
1
Parent(s):
3ee6e19
Update file_utils.py
Browse filesadd speed_change function
cosyvoice/utils/file_utils.py
CHANGED
@@ -39,3 +39,15 @@ def load_wav(wav, target_sr):
|
|
39 |
assert sample_rate > target_sr, 'wav sample rate {} must be greater than {}'.format(sample_rate, target_sr)
|
40 |
speech = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=target_sr)(speech)
|
41 |
return speech
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
assert sample_rate > target_sr, 'wav sample rate {} must be greater than {}'.format(sample_rate, target_sr)
|
40 |
speech = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=target_sr)(speech)
|
41 |
return speech
|
42 |
+
|
43 |
+
def speed_change(waveform,sample_rate,speed_factor:str):
|
44 |
+
effects = [
|
45 |
+
["tempo",speed_factor], # speed_factor
|
46 |
+
["rate", f"{sample_rate}"]
|
47 |
+
]
|
48 |
+
augmented_waveform, new_sample_rate = torchaudio.sox_effects.apply_effects_tensor(
|
49 |
+
waveform,
|
50 |
+
sample_rate,
|
51 |
+
effects
|
52 |
+
)
|
53 |
+
return augmented_waveform, new_sample_rate
|