Upload openbmb_VoxCPM1.5_0.py with huggingface_hub
Browse files- openbmb_VoxCPM1.5_0.py +90 -0
openbmb_VoxCPM1.5_0.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /// script
|
| 2 |
+
# requires-python = ">=3.12"
|
| 3 |
+
# dependencies = [
|
| 4 |
+
# "numpy",
|
| 5 |
+
# "einops",
|
| 6 |
+
# "pandas",
|
| 7 |
+
# "matplotlib",
|
| 8 |
+
# "protobuf",
|
| 9 |
+
# "torch",
|
| 10 |
+
# "sentencepiece",
|
| 11 |
+
# "torchvision",
|
| 12 |
+
# "transformers",
|
| 13 |
+
# "timm",
|
| 14 |
+
# "diffusers",
|
| 15 |
+
# "sentence-transformers",
|
| 16 |
+
# "accelerate",
|
| 17 |
+
# "peft",
|
| 18 |
+
# "slack-sdk",
|
| 19 |
+
# ]
|
| 20 |
+
# ///
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
import soundfile as sf
|
| 24 |
+
from voxcpm import VoxCPM
|
| 25 |
+
|
| 26 |
+
model = VoxCPM.from_pretrained("openbmb/VoxCPM1.5")
|
| 27 |
+
|
| 28 |
+
wav = model.generate(
|
| 29 |
+
text="VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech.",
|
| 30 |
+
prompt_wav_path=None, # optional: path to a prompt speech for voice cloning
|
| 31 |
+
prompt_text=None, # optional: reference text
|
| 32 |
+
cfg_value=2.0, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse
|
| 33 |
+
inference_timesteps=10, # LocDiT inference timesteps, higher for better result, lower for fast speed
|
| 34 |
+
normalize=True, # enable external TN tool
|
| 35 |
+
denoise=True, # enable external Denoise tool
|
| 36 |
+
retry_badcase=True, # enable retrying mode for some bad cases (unstoppable)
|
| 37 |
+
retry_badcase_max_times=3, # maximum retrying times
|
| 38 |
+
retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
sf.write("output.wav", wav, 16000)
|
| 42 |
+
print("saved: output.wav")
|
| 43 |
+
with open('openbmb_VoxCPM1.5_0.txt', 'w', encoding='utf-8') as f:
|
| 44 |
+
f.write('Everything was good in openbmb_VoxCPM1.5_0.txt')
|
| 45 |
+
except Exception as e:
|
| 46 |
+
import os
|
| 47 |
+
from slack_sdk import WebClient
|
| 48 |
+
client = WebClient(token=os.environ['SLACK_TOKEN'])
|
| 49 |
+
client.chat_postMessage(
|
| 50 |
+
channel='#hub-model-metadata-snippets-sprint',
|
| 51 |
+
text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/openbmb_VoxCPM1.5_0.txt|openbmb_VoxCPM1.5_0.txt>',
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
with open('openbmb_VoxCPM1.5_0.txt', 'a', encoding='utf-8') as f:
|
| 55 |
+
import traceback
|
| 56 |
+
f.write('''```CODE:
|
| 57 |
+
import soundfile as sf
|
| 58 |
+
from voxcpm import VoxCPM
|
| 59 |
+
|
| 60 |
+
model = VoxCPM.from_pretrained("openbmb/VoxCPM1.5")
|
| 61 |
+
|
| 62 |
+
wav = model.generate(
|
| 63 |
+
text="VoxCPM is an innovative end-to-end TTS model from ModelBest, designed to generate highly expressive speech.",
|
| 64 |
+
prompt_wav_path=None, # optional: path to a prompt speech for voice cloning
|
| 65 |
+
prompt_text=None, # optional: reference text
|
| 66 |
+
cfg_value=2.0, # LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse
|
| 67 |
+
inference_timesteps=10, # LocDiT inference timesteps, higher for better result, lower for fast speed
|
| 68 |
+
normalize=True, # enable external TN tool
|
| 69 |
+
denoise=True, # enable external Denoise tool
|
| 70 |
+
retry_badcase=True, # enable retrying mode for some bad cases (unstoppable)
|
| 71 |
+
retry_badcase_max_times=3, # maximum retrying times
|
| 72 |
+
retry_badcase_ratio_threshold=6.0, # maximum length restriction for bad case detection (simple but effective), it could be adjusted for slow pace speech
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
sf.write("output.wav", wav, 16000)
|
| 76 |
+
print("saved: output.wav")
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
ERROR:
|
| 80 |
+
''')
|
| 81 |
+
traceback.print_exc(file=f)
|
| 82 |
+
|
| 83 |
+
finally:
|
| 84 |
+
from huggingface_hub import upload_file
|
| 85 |
+
upload_file(
|
| 86 |
+
path_or_fileobj='openbmb_VoxCPM1.5_0.txt',
|
| 87 |
+
repo_id='model-metadata/code_execution_files',
|
| 88 |
+
path_in_repo='openbmb_VoxCPM1.5_0.txt',
|
| 89 |
+
repo_type='dataset',
|
| 90 |
+
)
|