ariG23498 HF Staff commited on
Commit
acb290e
·
verified ·
1 Parent(s): df7c597

Upload hexgrad_Kokoro-82M_2.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. hexgrad_Kokoro-82M_2.py +36 -0
hexgrad_Kokoro-82M_2.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "transformers",
5
+ # "torch",
6
+ # ]
7
+ # ///
8
+
9
+ try:
10
+ import os
11
+ from huggingface_hub import InferenceClient
12
+
13
+ client = InferenceClient(
14
+ provider="auto",
15
+ api_key=os.environ["HF_TOKEN"],
16
+ )
17
+
18
+ # audio is returned as bytes
19
+ audio = client.text_to_speech(
20
+ "The answer to the universe is 42",
21
+ model="hexgrad/Kokoro-82M",
22
+ )
23
+ with open('hexgrad_Kokoro-82M_2.txt', 'w') as f:
24
+ f.write('Everything was good in hexgrad_Kokoro-82M_2.txt')
25
+ except Exception as e:
26
+ with open('hexgrad_Kokoro-82M_2.txt', 'w') as f:
27
+ import traceback
28
+ traceback.print_exc(file=f)
29
+ finally:
30
+ from huggingface_hub import upload_file
31
+ upload_file(
32
+ path_or_fileobj='hexgrad_Kokoro-82M_2.txt',
33
+ repo_id='model-metadata/custom_code_execution_files',
34
+ path_in_repo='hexgrad_Kokoro-82M_2.txt',
35
+ repo_type='dataset',
36
+ )