ariG23498 HF Staff commited on
Commit
cebcc86
·
verified ·
1 Parent(s): 0cb8992

Upload openai_whisper-large-v3_3.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. openai_whisper-large-v3_3.py +59 -0
openai_whisper-large-v3_3.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "torch",
5
+ # "torchvision",
6
+ # "transformers",
7
+ # "accelerate",
8
+ # "peft",
9
+ # "slack-sdk",
10
+ # ]
11
+ # ///
12
+
13
+ try:
14
+ import os
15
+ from huggingface_hub import InferenceClient
16
+
17
+ client = InferenceClient(
18
+ provider="auto",
19
+ api_key=os.environ["HF_TOKEN"],
20
+ )
21
+
22
+ output = client.automatic_speech_recognition("sample1.flac", model="openai/whisper-large-v3")
23
+ with open('openai_whisper-large-v3_3.txt', 'w', encoding='utf-8') as f:
24
+ f.write('Everything was good in openai_whisper-large-v3_3.txt')
25
+ except Exception as e:
26
+ import os
27
+ from slack_sdk import WebClient
28
+ client = WebClient(token=os.environ['SLACK_TOKEN'])
29
+ client.chat_postMessage(
30
+ channel='#exp-slack-alerts',
31
+ text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/openai_whisper-large-v3_3.txt|openai_whisper-large-v3_3.txt>',
32
+ )
33
+
34
+ with open('openai_whisper-large-v3_3.txt', 'a', encoding='utf-8') as f:
35
+ import traceback
36
+ f.write('''```CODE:
37
+ import os
38
+ from huggingface_hub import InferenceClient
39
+
40
+ client = InferenceClient(
41
+ provider="auto",
42
+ api_key=os.environ["HF_TOKEN"],
43
+ )
44
+
45
+ output = client.automatic_speech_recognition("sample1.flac", model="openai/whisper-large-v3")
46
+ ```
47
+
48
+ ERROR:
49
+ ''')
50
+ traceback.print_exc(file=f)
51
+
52
+ finally:
53
+ from huggingface_hub import upload_file
54
+ upload_file(
55
+ path_or_fileobj='openai_whisper-large-v3_3.txt',
56
+ repo_id='model-metadata/code_execution_files',
57
+ path_in_repo='openai_whisper-large-v3_3.txt',
58
+ repo_type='dataset',
59
+ )