tykiww commited on
Commit
8f92dc6
β€’
1 Parent(s): 7e338ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -52,21 +52,24 @@ def default_table():
52
  "Title": ["", "", "", "", ""]
53
  })
54
 
 
 
 
 
 
 
55
 
56
 
57
  def substitute_names(speaker_names, text):
 
58
  df = speaker_names.itertuples(index=False)
59
  for default, name, title in df:
60
  if title != "":
61
- title = " ("+title+")"
62
-
63
- text = text.replace(default, f"{name}{title}")
64
-
65
- # Generate a unique temporary file name
66
- temp_file = tempfile.NamedTemporaryFile(suffix='.txt', delete=False)
67
- temp_file_name = temp_file.name
68
- temp_file.close() # Close the file to allow other processes to access it
69
 
 
 
70
  with open(temp_file_name, "w") as file:
71
  file.write(text)
72
 
@@ -87,12 +90,12 @@ def main(conf):
87
  gr.Markdown("# πŸ”Š Upload or record your meeting")
88
  audio_input = gr.Audio(type="filepath", label="Upload Audio File")
89
  num_speakers = gr.Dropdown(list(range(conf["session"]["min_speakers"],
90
- conf["session"]["max_speakers"])),
91
  label="Number of Speakers",
92
  value=conf["session"]["min_speakers"])
93
 
94
  process_button = gr.Button("Process")
95
- output_box = gr.Textbox()
96
 
97
 
98
  with gr.TabItem(conf["layout"]["page_names"][2]):
@@ -100,7 +103,7 @@ def main(conf):
100
  transcription_output = gr.Textbox(label="Transcription Review")
101
 
102
  speaker_names = gr.Dataframe(
103
- label="Match output names to desired names and titles/responsibility. Only enter values for ",
104
  headers=["Default", "Name", "Title"],
105
  datatype=["str", "str"],
106
  row_count=(5,"fixed"),
 
52
  "Title": ["", "", "", "", ""]
53
  })
54
 
55
+ def tempfile_generator():
56
+ # Generate a unique temporary file name
57
+ temp_file = tempfile.NamedTemporaryFile(suffix='.txt', delete=False)
58
+ temp_file_name = temp_file.name
59
+ temp_file.close()
60
+ return temp_file_name
61
 
62
 
63
  def substitute_names(speaker_names, text):
64
+ # Clean Speaker names
65
  df = speaker_names.itertuples(index=False)
66
  for default, name, title in df:
67
  if title != "":
68
+ title = " ("+title.strip()+")"
69
+ text = text.replace(default, f"{name.strip()}{title}")
 
 
 
 
 
 
70
 
71
+ # Make file downloadable
72
+ temp_file_name = tempfile_generator()
73
  with open(temp_file_name, "w") as file:
74
  file.write(text)
75
 
 
90
  gr.Markdown("# πŸ”Š Upload or record your meeting")
91
  audio_input = gr.Audio(type="filepath", label="Upload Audio File")
92
  num_speakers = gr.Dropdown(list(range(conf["session"]["min_speakers"],
93
+ conf["session"]["max_speakers"]+1)),
94
  label="Number of Speakers",
95
  value=conf["session"]["min_speakers"])
96
 
97
  process_button = gr.Button("Process")
98
+ output_box = gr.Textbox("Progress")
99
 
100
 
101
  with gr.TabItem(conf["layout"]["page_names"][2]):
 
103
  transcription_output = gr.Textbox(label="Transcription Review")
104
 
105
  speaker_names = gr.Dataframe(
106
+ label="Match output names to desired names and titles/responsibility. Only enter values for Name and Title",
107
  headers=["Default", "Name", "Title"],
108
  datatype=["str", "str"],
109
  row_count=(5,"fixed"),