Spaces:
Sleeping
Sleeping
commented out print stat
Browse files
server.py
CHANGED
@@ -45,7 +45,7 @@ async def predictor(names, file_uploads, usersNum, recordingsNum):
|
|
45 |
speaker_wavs_list = []
|
46 |
fileInd = 0
|
47 |
names.pop() # to remove key named "test"
|
48 |
-
print("file_uploads ", file_uploads, "recordingNums ", recordingsNum)
|
49 |
for name in names:
|
50 |
wav_fpaths = []
|
51 |
for ind in range(int(recordingsNum)):
|
@@ -59,46 +59,46 @@ async def predictor(names, file_uploads, usersNum, recordingsNum):
|
|
59 |
file_object.write(data)
|
60 |
wav_fpaths.append(Path(file_path))
|
61 |
fileInd += 1
|
62 |
-
print("wav_fpaths len", len(wav_fpaths), "name", name)
|
63 |
try:
|
64 |
speaker_wavs = {speaker: list(map(preprocess_wav, wav_fpaths)) for speaker, wav_fpaths in
|
65 |
groupby(tqdm(wav_fpaths, "Preprocessing wavs", len(wav_fpaths), unit="wavs"),
|
66 |
lambda wav_fpath: os.path.basename(wav_fpath).split("¬")[0])} # extracting person's name from file name
|
67 |
speaker_wavs_list.append(speaker_wavs)
|
68 |
except Exception as e:
|
69 |
-
print("
|
|
|
70 |
|
71 |
# make a list of the pre-processed audios ki arrays
|
72 |
for sp_wvs in speaker_wavs_list:
|
73 |
speaker_embed_list.append(
|
74 |
np.array([encoder.embed_speaker(wavs) for wavs in sp_wvs.values()]))
|
75 |
|
76 |
-
print("preprocessed audio ki array ", speaker_embed_list)
|
77 |
# making preprocessed test audio
|
78 |
wav_fpaths = []
|
79 |
file_upload = file_uploads[-1]
|
80 |
data = await file_upload.read()
|
81 |
-
print("data", data)
|
82 |
filename = "test¬"+file_upload.filename
|
83 |
file_path = UPLOAD_DIR / filename
|
84 |
-
print("filepath", file_path)
|
85 |
with open(file_path, "wb") as file_object:
|
86 |
file_object.write(data)
|
87 |
|
88 |
wav_fpaths.append(Path(file_path))
|
89 |
-
print("wav_fpath", wav_fpaths)
|
90 |
-
print("about to test
|
91 |
try:
|
92 |
test_pos_wavs = {speaker: list(map(preprocess_wav, wav_fpaths)) for speaker, wav_fpaths in
|
93 |
groupby(tqdm(wav_fpaths, "Preprocessing wavs", len(wav_fpaths), unit="wavs"),
|
94 |
lambda wav_fpath: "test")}
|
95 |
-
print("test_pos_wavs", test_pos_wavs)
|
96 |
except Exception as error:
|
97 |
print("An exception occurred:", type(error).__name__)
|
98 |
print("Exception details:", error)
|
99 |
test_pos_emb = np.array([encoder.embed_speaker(wavs)
|
100 |
for wavs in test_pos_wavs.values()])
|
101 |
-
# print("test error ", error)
|
102 |
|
103 |
# calculates cosine similarity between the ground truth (test file) and registered audios
|
104 |
speakers = {}
|
|
|
45 |
speaker_wavs_list = []
|
46 |
fileInd = 0
|
47 |
names.pop() # to remove key named "test"
|
48 |
+
# print("file_uploads ", file_uploads, "recordingNums ", recordingsNum)
|
49 |
for name in names:
|
50 |
wav_fpaths = []
|
51 |
for ind in range(int(recordingsNum)):
|
|
|
59 |
file_object.write(data)
|
60 |
wav_fpaths.append(Path(file_path))
|
61 |
fileInd += 1
|
62 |
+
# print("wav_fpaths len", len(wav_fpaths), "name", name)
|
63 |
try:
|
64 |
speaker_wavs = {speaker: list(map(preprocess_wav, wav_fpaths)) for speaker, wav_fpaths in
|
65 |
groupby(tqdm(wav_fpaths, "Preprocessing wavs", len(wav_fpaths), unit="wavs"),
|
66 |
lambda wav_fpath: os.path.basename(wav_fpath).split("¬")[0])} # extracting person's name from file name
|
67 |
speaker_wavs_list.append(speaker_wavs)
|
68 |
except Exception as e:
|
69 |
+
print("An exception occurred:", type(error).__name__)
|
70 |
+
print("Exception details:", error)
|
71 |
|
72 |
# make a list of the pre-processed audios ki arrays
|
73 |
for sp_wvs in speaker_wavs_list:
|
74 |
speaker_embed_list.append(
|
75 |
np.array([encoder.embed_speaker(wavs) for wavs in sp_wvs.values()]))
|
76 |
|
77 |
+
# print("preprocessed audio ki array ", speaker_embed_list)
|
78 |
# making preprocessed test audio
|
79 |
wav_fpaths = []
|
80 |
file_upload = file_uploads[-1]
|
81 |
data = await file_upload.read()
|
82 |
+
# print("data", data)
|
83 |
filename = "test¬"+file_upload.filename
|
84 |
file_path = UPLOAD_DIR / filename
|
85 |
+
# print("filepath", file_path)
|
86 |
with open(file_path, "wb") as file_object:
|
87 |
file_object.write(data)
|
88 |
|
89 |
wav_fpaths.append(Path(file_path))
|
90 |
+
# print("wav_fpath", wav_fpaths)
|
91 |
+
print("about to test")
|
92 |
try:
|
93 |
test_pos_wavs = {speaker: list(map(preprocess_wav, wav_fpaths)) for speaker, wav_fpaths in
|
94 |
groupby(tqdm(wav_fpaths, "Preprocessing wavs", len(wav_fpaths), unit="wavs"),
|
95 |
lambda wav_fpath: "test")}
|
96 |
+
# print("test_pos_wavs", test_pos_wavs)
|
97 |
except Exception as error:
|
98 |
print("An exception occurred:", type(error).__name__)
|
99 |
print("Exception details:", error)
|
100 |
test_pos_emb = np.array([encoder.embed_speaker(wavs)
|
101 |
for wavs in test_pos_wavs.values()])
|
|
|
102 |
|
103 |
# calculates cosine similarity between the ground truth (test file) and registered audios
|
104 |
speakers = {}
|