awacke1 commited on
Commit
e8470c7
1 Parent(s): 27065d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -13
app.py CHANGED
@@ -30,18 +30,22 @@ DATA_FILENAME = "ASRLive.csv"
30
  DATA_FILE = os.path.join("data", DATA_FILENAME)
31
  HF_TOKEN = os.environ.get("HF_TOKEN")
32
 
33
- try:
34
- hf_hub_download(
35
- repo_id=DATASET_REPO_ID,
36
- filename=DATA_FILENAME,
37
- cache_dir=DATA_DIRNAME,
38
- force_filename=DATA_FILENAME
 
 
 
 
 
 
 
 
 
39
  )
40
- except:
41
- print("file not found")
42
- repo = Repository(
43
- local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
44
- )
45
 
46
  def store_message(name: str, message: str):
47
  if name and message:
@@ -106,8 +110,12 @@ def transcribe(audio, state = ""):
106
  if type(transcriptions) == tuple and len(transcriptions) == 2:
107
  transcriptions = transcriptions[0]
108
  transcriptions = transcriptions[0]
109
- ret = store_message(transcriptions, state) # Save to dataset - uncomment to store into a dataset - hint you will need your HF_TOKEN
110
- state = state + transcriptions + " " + ret
 
 
 
 
111
  return state, state
112
 
113
  gr.Interface(
 
30
  DATA_FILE = os.path.join("data", DATA_FILENAME)
31
  HF_TOKEN = os.environ.get("HF_TOKEN")
32
 
33
+ PersistToDataset = False
34
+ #PersistToDataset = True # uncomment to save inference output to ASRLive.csv dataset
35
+
36
+ if PersistToDataset:
37
+ try:
38
+ hf_hub_download(
39
+ repo_id=DATASET_REPO_ID,
40
+ filename=DATA_FILENAME,
41
+ cache_dir=DATA_DIRNAME,
42
+ force_filename=DATA_FILENAME
43
+ )
44
+ except:
45
+ print("file not found")
46
+ repo = Repository(
47
+ local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
48
  )
 
 
 
 
 
49
 
50
  def store_message(name: str, message: str):
51
  if name and message:
 
110
  if type(transcriptions) == tuple and len(transcriptions) == 2:
111
  transcriptions = transcriptions[0]
112
  transcriptions = transcriptions[0]
113
+
114
+ if PersistToDataset:
115
+ ret = store_message(transcriptions, state) # Save to dataset - uncomment to store into a dataset - hint you will need your HF_TOKEN
116
+ state = state + transcriptions + " " + ret
117
+ else:
118
+ state = state + transcriptions
119
  return state, state
120
 
121
  gr.Interface(