ariG23498 HF Staff commited on
Commit
e1153c1
·
verified ·
1 Parent(s): f64038b

Upload openai_whisper-large-v3_3.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. openai_whisper-large-v3_3.py +32 -0
openai_whisper-large-v3_3.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ output = client.automatic_speech_recognition("sample1.flac", model="openai/whisper-large-v3")
19
+ with open('openai_whisper-large-v3_3.txt', 'w') as f:
20
+ f.write('Everything was good in openai_whisper-large-v3_3.txt')
21
+ except Exception as e:
22
+ with open('openai_whisper-large-v3_3.txt', 'w') as f:
23
+ import traceback
24
+ traceback.print_exc(file=f)
25
+ finally:
26
+ from huggingface_hub import upload_file
27
+ upload_file(
28
+ path_or_fileobj='openai_whisper-large-v3_3.txt',
29
+ repo_id='model-metadata/custom_code_execution_files',
30
+ path_in_repo='openai_whisper-large-v3_3.txt',
31
+ repo_type='dataset',
32
+ )