model-metadata/code_python_files
013k
1# /// script2# 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 22try:23 from supertonic import TTS24 25 tts = TTS(auto_download=True)26 27 style = tts.get_voice_style(voice_name="M1")28 29 text = "The train delay was announced at 4:45 PM on Wed, Apr 3, 2024 due to track maintenance."30 wav, duration = tts.synthesize(text, voice_style=style)31 32 tts.save_audio(wav, "output.wav")33 with open('Supertone_supertonic-2_0.txt', 'w', encoding='utf-8') as f:34 f.write('Everything was good in Supertone_supertonic-2_0.txt')35except Exception as e:36 import os37 from slack_sdk import WebClient38 client = WebClient(token=os.environ['SLACK_TOKEN'])39 client.chat_postMessage(40 channel='#hub-model-metadata-snippets-sprint',41 text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/Supertone_supertonic-2_0.txt|Supertone_supertonic-2_0.txt>',42 )43 44 with open('Supertone_supertonic-2_0.txt', 'a', encoding='utf-8') as f:45 import traceback46 f.write('''```CODE: 47from supertonic import TTS48 49tts = TTS(auto_download=True)50 51style = tts.get_voice_style(voice_name="M1")52 53text = "The train delay was announced at 4:45 PM on Wed, Apr 3, 2024 due to track maintenance."54wav, duration = tts.synthesize(text, voice_style=style)55 56tts.save_audio(wav, "output.wav")57```58 59ERROR: 60''')61 traceback.print_exc(file=f)62 63finally:64 from huggingface_hub import upload_file65 upload_file(66 path_or_fileobj='Supertone_supertonic-2_0.txt',67 repo_id='model-metadata/code_execution_files',68 path_in_repo='Supertone_supertonic-2_0.txt',69 repo_type='dataset',70 )71 