Spaces:
Sleeping
Sleeping
Commit ·
fe075ed
1
Parent(s): 304fe97
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,17 +16,14 @@ import contextlib
|
|
| 16 |
|
| 17 |
from sklearn.cluster import AgglomerativeClustering
|
| 18 |
import numpy as np
|
| 19 |
-
|
| 20 |
-
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 21 |
|
| 22 |
model = whisper.load_model("large-v2")
|
| 23 |
embedding_model = PretrainedSpeakerEmbedding(
|
| 24 |
"speechbrain/spkrec-ecapa-voxceleb",
|
| 25 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 26 |
-
|
| 27 |
|
| 28 |
-
output=""
|
| 29 |
-
######################################################
|
| 30 |
def audio_to_text(audio, num_speakers):
|
| 31 |
path, error = convert_to_wav(audio)
|
| 32 |
if error is not None:
|
|
@@ -36,7 +33,6 @@ def audio_to_text(audio, num_speakers):
|
|
| 36 |
if duration > 4 * 60 * 60:
|
| 37 |
return "Audio duration too long"
|
| 38 |
|
| 39 |
-
|
| 40 |
result = model.transcribe(path)
|
| 41 |
segments = result["segments"]
|
| 42 |
|
|
@@ -48,7 +44,6 @@ def audio_to_text(audio, num_speakers):
|
|
| 48 |
add_speaker_labels(segments, embeddings, num_speakers)
|
| 49 |
global output
|
| 50 |
output = get_output(segments)
|
| 51 |
-
#short_sum=text_to_short_summary(str(output))
|
| 52 |
return output
|
| 53 |
|
| 54 |
def convert_to_wav(path):
|
|
@@ -100,10 +95,7 @@ def get_output(segments):
|
|
| 100 |
output += '\n\n'
|
| 101 |
output += segment["speaker"] + ' ' + str(time(segment["start"])) + '\n\n'
|
| 102 |
output += segment["text"][1:] + ' '
|
| 103 |
-
|
| 104 |
-
return output
|
| 105 |
-
|
| 106 |
-
#########################################################################
|
| 107 |
|
| 108 |
|
| 109 |
def text_to_short_summary():
|
|
|
|
| 16 |
|
| 17 |
from sklearn.cluster import AgglomerativeClustering
|
| 18 |
import numpy as np
|
| 19 |
+
optput=""
|
|
|
|
| 20 |
|
| 21 |
model = whisper.load_model("large-v2")
|
| 22 |
embedding_model = PretrainedSpeakerEmbedding(
|
| 23 |
"speechbrain/spkrec-ecapa-voxceleb",
|
| 24 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 25 |
+
)
|
| 26 |
|
|
|
|
|
|
|
| 27 |
def audio_to_text(audio, num_speakers):
|
| 28 |
path, error = convert_to_wav(audio)
|
| 29 |
if error is not None:
|
|
|
|
| 33 |
if duration > 4 * 60 * 60:
|
| 34 |
return "Audio duration too long"
|
| 35 |
|
|
|
|
| 36 |
result = model.transcribe(path)
|
| 37 |
segments = result["segments"]
|
| 38 |
|
|
|
|
| 44 |
add_speaker_labels(segments, embeddings, num_speakers)
|
| 45 |
global output
|
| 46 |
output = get_output(segments)
|
|
|
|
| 47 |
return output
|
| 48 |
|
| 49 |
def convert_to_wav(path):
|
|
|
|
| 95 |
output += '\n\n'
|
| 96 |
output += segment["speaker"] + ' ' + str(time(segment["start"])) + '\n\n'
|
| 97 |
output += segment["text"][1:] + ' '
|
| 98 |
+
return output
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
|
| 101 |
def text_to_short_summary():
|