cfc-tech commited on
Commit
248c174
·
verified ·
1 Parent(s): fa63d63

Update app

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -45,25 +45,28 @@ if st.button('Summarize'):
45
  logits = model(input_values).logits
46
  predicted_ids = torch.argmax(logits, dim=-1)
47
 
48
- # Decode the speech
49
- transcription = tokenizer.batch_decode(predicted_ids, skip_special_tokens=True)[0] # Ensure transcription is a single string
50
 
51
  # Ensure transcription is a string and not empty
52
  if isinstance(transcription, str) and transcription.strip():
 
 
53
  # Show progress
54
  st.progress(75)
55
 
56
  # Summarization
57
  summarizer = pipeline("summarization")
58
- summary = summarizer(transcription, max_length=130, min_length=30, do_sample=False)
59
-
60
- # Display the summary
61
- st.success("Done!")
62
- st.write("### Summary:")
63
- st.write(summary[0]['summary_text'])
64
 
65
- # Final progress
66
- st.progress(100)
 
 
67
  else:
68
  st.error("Could not transcribe audio or transcription is empty.")
69
 
 
45
  logits = model(input_values).logits
46
  predicted_ids = torch.argmax(logits, dim=-1)
47
 
48
+ # Decode the speech to text
49
+ transcription = tokenizer.batch_decode(predicted_ids, skip_special_tokens=True)[0]
50
 
51
  # Ensure transcription is a string and not empty
52
  if isinstance(transcription, str) and transcription.strip():
53
+ st.write("Transcription:", transcription) # Debugging print
54
+
55
  # Show progress
56
  st.progress(75)
57
 
58
  # Summarization
59
  summarizer = pipeline("summarization")
60
+ try:
61
+ summary = summarizer(transcription, max_length=130, min_length=30, do_sample=False)
62
+ st.success("Done!")
63
+ st.write("### Summary:")
64
+ st.write(summary[0]['summary_text'])
 
65
 
66
+ # Final progress
67
+ st.progress(100)
68
+ except Exception as e:
69
+ st.error(f"Error in summarization: {e}") # More specific error message
70
  else:
71
  st.error("Could not transcribe audio or transcription is empty.")
72