ariG23498 HF Staff commited on
Commit
ecf17df
·
verified ·
1 Parent(s): 45ea132

Upload Supertone_supertonic-2_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. Supertone_supertonic-2_0.py +70 -0
Supertone_supertonic-2_0.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from supertonic import TTS
24
+
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')
35
+ except Exception as e:
36
+ import os
37
+ from slack_sdk import WebClient
38
+ 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 traceback
46
+ f.write('''```CODE:
47
+ from supertonic import TTS
48
+
49
+ tts = TTS(auto_download=True)
50
+
51
+ style = tts.get_voice_style(voice_name="M1")
52
+
53
+ text = "The train delay was announced at 4:45 PM on Wed, Apr 3, 2024 due to track maintenance."
54
+ wav, duration = tts.synthesize(text, voice_style=style)
55
+
56
+ tts.save_audio(wav, "output.wav")
57
+ ```
58
+
59
+ ERROR:
60
+ ''')
61
+ traceback.print_exc(file=f)
62
+
63
+ finally:
64
+ from huggingface_hub import upload_file
65
+ 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
+ )