mazesmazes commited on
Commit
796207e
·
verified ·
1 Parent(s): ea205c1

Deploy demo to HF Space

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-312.pyc +0 -0
  2. app.py +19 -11
__pycache__/app.cpython-312.pyc CHANGED
Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ
 
app.py CHANGED
@@ -96,21 +96,34 @@ def speaker_turns(words):
96
 
97
 
98
  def conversation_html(words):
99
- """Speaker-attributed transcript: one color-coded block per speaker turn."""
 
 
 
 
100
  turns = speaker_turns(words)
101
  if not turns:
102
- return '<p class="empty">Turn on speaker diarization to see who said what.</p>'
 
 
 
103
  colors = {}
104
  for speaker, *_ in turns:
105
  colors.setdefault(speaker, SPEAKER_COLORS[len(colors) % len(SPEAKER_COLORS)])
106
  blocks = [
107
- f'<div class="turn" style="border-left-color:{colors[s]}">'
108
- f'<div class="who" style="color:{colors[s]}">{html.escape(speaker_label(s))}'
109
- f'<span class="when">{format_timestamp(start)} – {format_timestamp(end)}</span></div>'
 
 
 
110
  f"<div>{html.escape(text)}</div></div>"
111
  for s, start, end, text in turns
112
  ]
113
- return '<div class="conversation">' + "".join(blocks) + "</div>"
 
 
 
114
 
115
 
116
  def segment_rows(segments):
@@ -135,11 +148,6 @@ CSS = """
135
  .gradio-container { max-width: 1120px !important; margin: 0 auto !important; }
136
  #header h1 { margin-bottom: 0.25rem; }
137
  #header p { color: var(--body-text-color-subdued); margin-top: 0; }
138
- .conversation { display: flex; flex-direction: column; gap: 0.6rem; max-height: 420px; overflow-y: auto; }
139
- .turn { border-left: 4px solid; padding: 0.35rem 0.75rem; background: var(--background-fill-secondary); border-radius: 0 6px 6px 0; }
140
- .turn .who { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.15rem; }
141
- .turn .when { font-weight: 400; color: var(--body-text-color-subdued); margin-left: 0.5rem; }
142
- .empty { color: var(--body-text-color-subdued); }
143
  """
144
 
145
  EXAMPLE = Path(__file__).parent / "examples" / "ami_meeting.wav"
 
96
 
97
 
98
  def conversation_html(words):
99
+ """Speaker-attributed transcript: one color-coded block per speaker turn.
100
+
101
+ Styled inline rather than through the app's CSS: on Spaces this block
102
+ rendered without the stylesheet's rules (only inline colors survived).
103
+ """
104
  turns = speaker_turns(words)
105
  if not turns:
106
+ return (
107
+ '<p style="color:var(--body-text-color-subdued)">'
108
+ "Turn on speaker diarization to see who said what.</p>"
109
+ )
110
  colors = {}
111
  for speaker, *_ in turns:
112
  colors.setdefault(speaker, SPEAKER_COLORS[len(colors) % len(SPEAKER_COLORS)])
113
  blocks = [
114
+ f'<div style="border-left:4px solid {colors[s]};padding:0.35rem 0.75rem;'
115
+ 'background:var(--background-fill-secondary);border-radius:0 6px 6px 0">'
116
+ f'<div style="color:{colors[s]};font-weight:600;font-size:0.85rem;margin-bottom:0.15rem">'
117
+ f"{html.escape(speaker_label(s))}"
118
+ '<span style="font-weight:400;color:var(--body-text-color-subdued);margin-left:0.5rem">'
119
+ f"{format_timestamp(start)} – {format_timestamp(end)}</span></div>"
120
  f"<div>{html.escape(text)}</div></div>"
121
  for s, start, end, text in turns
122
  ]
123
+ return (
124
+ '<div style="display:flex;flex-direction:column;gap:0.6rem;'
125
+ 'max-height:420px;overflow-y:auto">' + "".join(blocks) + "</div>"
126
+ )
127
 
128
 
129
  def segment_rows(segments):
 
148
  .gradio-container { max-width: 1120px !important; margin: 0 auto !important; }
149
  #header h1 { margin-bottom: 0.25rem; }
150
  #header p { color: var(--body-text-color-subdued); margin-top: 0; }
 
 
 
 
 
151
  """
152
 
153
  EXAMPLE = Path(__file__).parent / "examples" / "ami_meeting.wav"