update
Browse files- .gitignore +1 -0
- data/analysis/es-MX.zip +2 -2
- data/calling/52.zip +2 -2
- examples/calling_analysis/active_media_analysis.py +58 -0
- examples/calling_analysis/early_media_analysis.py +6 -0
- examples/count.py +2 -1
- examples/{make_test_audios.py → make_test_audios/make_test_audios.py} +38 -19
- examples/make_test_audios/make_test_audios2.py +177 -0
- examples/make_test_audios/make_test_audios3.py +100 -0
- examples/make_test_audios/step_2_make_excel.py +52 -0
- requirements.txt +1 -0
.gitignore
CHANGED
|
@@ -9,6 +9,7 @@
|
|
| 9 |
|
| 10 |
data/analysis/en-SG
|
| 11 |
data/analysis/es-MX
|
|
|
|
| 12 |
data/analysis/ko-KR
|
| 13 |
data/analysis/ms-MY
|
| 14 |
data/analysis/pt-BR
|
|
|
|
| 9 |
|
| 10 |
data/analysis/en-SG
|
| 11 |
data/analysis/es-MX
|
| 12 |
+
data/analysis/es-MX-2
|
| 13 |
data/analysis/ko-KR
|
| 14 |
data/analysis/ms-MY
|
| 15 |
data/analysis/pt-BR
|
data/analysis/es-MX.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:284581983c7cf8da0afb9ec3a80f74fa3511011e8810ee97c5c1d6304190475a
|
| 3 |
+
size 17525404
|
data/calling/52.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c7fdfdc5da4bca8ce7e53565b63815f3337ee67d5ae31ea1e949d57133d9f227
|
| 3 |
+
size 8153540
|
examples/calling_analysis/active_media_analysis.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import argparse
|
| 4 |
+
from collections import defaultdict
|
| 5 |
+
import json
|
| 6 |
+
import logging
|
| 7 |
+
import os
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
import sys
|
| 10 |
+
|
| 11 |
+
pwd = os.path.abspath(os.path.dirname(__file__))
|
| 12 |
+
sys.path.append(os.path.join(pwd, "../../"))
|
| 13 |
+
|
| 14 |
+
from gradio_client import Client, handle_file
|
| 15 |
+
from tqdm import tqdm
|
| 16 |
+
|
| 17 |
+
from project_settings import project_path
|
| 18 |
+
|
| 19 |
+
logger = logging.getLogger("main")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def get_args():
|
| 23 |
+
parser = argparse.ArgumentParser()
|
| 24 |
+
parser.add_argument(
|
| 25 |
+
"--filename",
|
| 26 |
+
default=(project_path / "data/analysis/es-MX-2/bell_and_machine_voice/active_media_r_0ff155cb-7f03-4696-acc8-46b76f477037.wav").as_posix(),
|
| 27 |
+
# default=r"D:\Users\tianx\HuggingSpaces\cc_audio_8\data\download_wav_by_task_excel",
|
| 28 |
+
type=str
|
| 29 |
+
)
|
| 30 |
+
args = parser.parse_args()
|
| 31 |
+
return args
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def main():
|
| 35 |
+
args = get_args()
|
| 36 |
+
|
| 37 |
+
client = Client("https://qgyd2021-cc-vad.hf.space/")
|
| 38 |
+
outputs = client.predict(
|
| 39 |
+
audio_file_t=handle_file(args.filename),
|
| 40 |
+
audio_microphone_t=None,
|
| 41 |
+
start_ring_rate=0.5,
|
| 42 |
+
end_ring_rate=0.3,
|
| 43 |
+
ring_max_length=10,
|
| 44 |
+
min_silence_length=6,
|
| 45 |
+
max_speech_length=100000,
|
| 46 |
+
min_speech_length=15,
|
| 47 |
+
engine="fsmn-vad-by-webrtcvad-nx2-dns3",
|
| 48 |
+
api_name="/when_click_vad_button"
|
| 49 |
+
)
|
| 50 |
+
_, _, _, vad_outputs = outputs
|
| 51 |
+
vad_outputs = json.loads(vad_outputs)
|
| 52 |
+
print(vad_outputs)
|
| 53 |
+
|
| 54 |
+
return
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
if __name__ == "__main__":
|
| 58 |
+
main()
|
examples/calling_analysis/early_media_analysis.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
if __name__ == "__main__":
|
| 6 |
+
pass
|
examples/count.py
CHANGED
|
@@ -19,7 +19,8 @@ def get_args():
|
|
| 19 |
parser = argparse.ArgumentParser()
|
| 20 |
parser.add_argument(
|
| 21 |
"--src_dir",
|
| 22 |
-
default=r"D:\Users\tianx\HuggingDatasets\calling_analysis\data\analysis\
|
|
|
|
| 23 |
type=str
|
| 24 |
)
|
| 25 |
args = parser.parse_args()
|
|
|
|
| 19 |
parser = argparse.ArgumentParser()
|
| 20 |
parser.add_argument(
|
| 21 |
"--src_dir",
|
| 22 |
+
default=r"D:\Users\tianx\HuggingDatasets\calling_analysis\data\analysis\es-MX",
|
| 23 |
+
# default=r"D:\Users\tianx\HuggingSpaces\cc_audio_8\data\download_wav_by_task_excel",
|
| 24 |
type=str
|
| 25 |
)
|
| 26 |
args = parser.parse_args()
|
examples/{make_test_audios.py → make_test_audios/make_test_audios.py}
RENAMED
|
@@ -14,12 +14,12 @@ def get_args():
|
|
| 14 |
parser = argparse.ArgumentParser()
|
| 15 |
parser.add_argument(
|
| 16 |
"--audio_dir",
|
| 17 |
-
default=(project_path / "data/analysis/
|
| 18 |
type=str
|
| 19 |
)
|
| 20 |
parser.add_argument(
|
| 21 |
"--output_dir",
|
| 22 |
-
default=(project_path / "data/calling/
|
| 23 |
type=str
|
| 24 |
)
|
| 25 |
args = parser.parse_args()
|
|
@@ -27,20 +27,32 @@ def get_args():
|
|
| 27 |
|
| 28 |
|
| 29 |
quantity_to_use = """
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
"""
|
| 45 |
|
| 46 |
|
|
@@ -54,9 +66,16 @@ def main():
|
|
| 54 |
call_id_to_wav_file_list = defaultdict(list)
|
| 55 |
for filename in audio_dir.glob("**/*.wav"):
|
| 56 |
splits = filename.stem.split("_")
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
call_id_to_wav_file_list[call_id].append(filename)
|
| 61 |
print(f"count: {len(call_id_to_wav_file_list)}")
|
| 62 |
|
|
|
|
| 14 |
parser = argparse.ArgumentParser()
|
| 15 |
parser.add_argument(
|
| 16 |
"--audio_dir",
|
| 17 |
+
default=(project_path / "data/analysis/es-MX").as_posix(),
|
| 18 |
type=str
|
| 19 |
)
|
| 20 |
parser.add_argument(
|
| 21 |
"--output_dir",
|
| 22 |
+
default=(project_path / "data/calling/52").as_posix(),
|
| 23 |
type=str
|
| 24 |
)
|
| 25 |
args = parser.parse_args()
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
quantity_to_use = """
|
| 30 |
+
bell_and_machine_voice: 6, 6%
|
| 31 |
+
bell_and_mute: 2, 2%
|
| 32 |
+
bell_and_mute_1_second_then_voicemail: 1, 1%
|
| 33 |
+
bell_and_noise: 4, 4%
|
| 34 |
+
bell_and_noise_mute: 3, 3%
|
| 35 |
+
bell_and_not_connected: 17, 17%
|
| 36 |
+
bell_and_voice: 10, 10%
|
| 37 |
+
bell_and_voicemail: 19, 19%
|
| 38 |
+
busy_and_not_connected: 11, 11%
|
| 39 |
+
busy_or_disconnected_or_out_of_coverage_and_not_connected: 1, 1%
|
| 40 |
+
disconnected_or_out_of_service_and_not_connected: 1, 1%
|
| 41 |
+
early_media_voicemail_and_custom_voicemail: 16, 16%
|
| 42 |
+
early_media_voicemail_and_mute_3s_then_voicemail: 5, 5%
|
| 43 |
+
early_media_voicemail_and_mute_5s_then_voicemail: 1, 1%
|
| 44 |
+
early_media_voicemail_and_not_connected: 11, 11%
|
| 45 |
+
early_media_voicemail_and_voicemail: 31, 31%
|
| 46 |
+
early_media_voicemail_is_full_and_not_connected: 9, 9%
|
| 47 |
+
music_and_voicemail: 2, 2%
|
| 48 |
+
mute_and_machine_voice: 4, 4%
|
| 49 |
+
mute_and_not_connected: 1, 1%
|
| 50 |
+
mute_and_voicemail: 3, 3%
|
| 51 |
+
no_early_media_and_mute_3s_then_busy: 1, 1%
|
| 52 |
+
no_early_media_and_voice: 2, 2%
|
| 53 |
+
out_of_service_and_not_connected: 2, 2%
|
| 54 |
+
unavailable_and_not_connected: 1, 1%
|
| 55 |
+
unavailable_or_out_of_service_and_not_connected: 2, 2%
|
| 56 |
"""
|
| 57 |
|
| 58 |
|
|
|
|
| 66 |
call_id_to_wav_file_list = defaultdict(list)
|
| 67 |
for filename in audio_dir.glob("**/*.wav"):
|
| 68 |
splits = filename.stem.split("_")
|
| 69 |
+
if len(splits) == 4:
|
| 70 |
+
call_id = splits[3]
|
| 71 |
+
# language = splits[4]
|
| 72 |
+
# scene_id = splits[5]
|
| 73 |
+
elif len(splits) == 5:
|
| 74 |
+
call_id = splits[3]
|
| 75 |
+
language = splits[4]
|
| 76 |
+
scene_id = splits[5]
|
| 77 |
+
else:
|
| 78 |
+
raise AssertionError(f"{filename.stem}")
|
| 79 |
call_id_to_wav_file_list[call_id].append(filename)
|
| 80 |
print(f"count: {len(call_id_to_wav_file_list)}")
|
| 81 |
|
examples/make_test_audios/make_test_audios2.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import argparse
|
| 4 |
+
import json
|
| 5 |
+
from collections import defaultdict
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
import shutil
|
| 8 |
+
|
| 9 |
+
import pandas as pd
|
| 10 |
+
from gradio_client import Client, handle_file
|
| 11 |
+
|
| 12 |
+
from project_settings import project_path
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def get_args():
|
| 16 |
+
parser = argparse.ArgumentParser()
|
| 17 |
+
parser.add_argument(
|
| 18 |
+
"--audio_dir",
|
| 19 |
+
default=(project_path / "data/analysis/pt-BR").as_posix(),
|
| 20 |
+
type=str
|
| 21 |
+
)
|
| 22 |
+
parser.add_argument(
|
| 23 |
+
"--output_file",
|
| 24 |
+
default=(project_path / "data/excel/pt-BR.jsonl").as_posix(),
|
| 25 |
+
type=str
|
| 26 |
+
)
|
| 27 |
+
args = parser.parse_args()
|
| 28 |
+
return args
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def get_simulate_label(label: str):
|
| 32 |
+
splits = label.split("_and_")
|
| 33 |
+
if len(splits) != 2:
|
| 34 |
+
raise AssertionError(f"invalid label: {label}")
|
| 35 |
+
|
| 36 |
+
label0 = splits[0]
|
| 37 |
+
label1 = splits[1]
|
| 38 |
+
|
| 39 |
+
if label1 in ("not_connected", "not_connected2"):
|
| 40 |
+
if label0 in ("bell",):
|
| 41 |
+
result = "响铃"
|
| 42 |
+
elif label0 in ("mute",):
|
| 43 |
+
result = "静音"
|
| 44 |
+
elif label0 in ("out_of_service",
|
| 45 |
+
"busy", "unavailable",
|
| 46 |
+
"busy_or_disconnected_or_out_of_coverage",
|
| 47 |
+
"disconnected_or_out_of_service",
|
| 48 |
+
"unavailable_or_out_of_service", "blocked_or_cannot_receive_this_call", "invalid_number", "unable_to_complete_this_call"
|
| 49 |
+
|
| 50 |
+
):
|
| 51 |
+
result = "运营商提示音"
|
| 52 |
+
elif label0 in ("early_media_voicemail", "early_media_voicemail_is_full"):
|
| 53 |
+
result = "留言信箱"
|
| 54 |
+
|
| 55 |
+
else:
|
| 56 |
+
raise AssertionError(f"invalid label: {label}")
|
| 57 |
+
|
| 58 |
+
else:
|
| 59 |
+
if label1 in ("voicemail", "mute_1_second_then_voicemail", "di_then_mute", "mute_4_second_then_voicemail"):
|
| 60 |
+
result = "语音信箱"
|
| 61 |
+
elif label1 in ("mute",):
|
| 62 |
+
result = "静音"
|
| 63 |
+
elif label1 in ("voice",):
|
| 64 |
+
result = "真人"
|
| 65 |
+
elif label1 in ("noise_mute", "noise"):
|
| 66 |
+
result = "其它"
|
| 67 |
+
|
| 68 |
+
else:
|
| 69 |
+
raise AssertionError(f"invalid label: {label}")
|
| 70 |
+
|
| 71 |
+
return result
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
s3_kwargs1 = {
|
| 75 |
+
"client": "aliyun",
|
| 76 |
+
"bucket_endpoint": "https://aicc-sit.oss-ap-southeast-1.aliyuncs.com",
|
| 77 |
+
"endpoint": "https://oss-ap-southeast-1.aliyuncs.com",
|
| 78 |
+
"region": "oss-ap-southeast-1",
|
| 79 |
+
"secret_key": "o3qdtbZLSZQR6OWZPYsiOmb5Zza5LF",
|
| 80 |
+
"secret_id": "LTAI5tCWWqAE7TBPn9fwhkoS",
|
| 81 |
+
"bucket": "aicc-sit",
|
| 82 |
+
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
s3_kwargs = {
|
| 86 |
+
"client": "botocore_s3",
|
| 87 |
+
"bucket_endpoint": "https://aicc-dev.oss-ap-southeast-1.aliyuncs.com",
|
| 88 |
+
"endpoint": "https://oss-ap-southeast-1.aliyuncs.com",
|
| 89 |
+
"region": "oss-ap-southeast-1",
|
| 90 |
+
"bucket": "aicc-dev",
|
| 91 |
+
"secret_id": "LTAI5tDFukW5fEJw5ezXGp3d",
|
| 92 |
+
"secret_key": "hiPGyeco2IsY0FwBZBwAbCWXAFnggA"
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
def main():
|
| 96 |
+
args = get_args()
|
| 97 |
+
audio_dir = Path(args.audio_dir)
|
| 98 |
+
output_file = Path(args.output_file)
|
| 99 |
+
output_file.parent.mkdir(parents=True, exist_ok=True)
|
| 100 |
+
|
| 101 |
+
client = Client("http://127.0.0.1:7861/")
|
| 102 |
+
language = audio_dir.parts[-1]
|
| 103 |
+
|
| 104 |
+
call_id_to_wav_file_list = defaultdict(list)
|
| 105 |
+
for filename in audio_dir.glob("**/*.wav"):
|
| 106 |
+
splits = filename.stem.split("_")
|
| 107 |
+
call_id = splits[3]
|
| 108 |
+
language = splits[4]
|
| 109 |
+
scene_id = splits[5]
|
| 110 |
+
call_id_to_wav_file_list[call_id].append(filename)
|
| 111 |
+
print(f"count: {len(call_id_to_wav_file_list)}")
|
| 112 |
+
|
| 113 |
+
result = list()
|
| 114 |
+
with open(output_file.as_posix(), "a+", encoding="utf-8") as f:
|
| 115 |
+
for call_id, wav_file_list in call_id_to_wav_file_list.items():
|
| 116 |
+
print(call_id)
|
| 117 |
+
label = None
|
| 118 |
+
early_media_r_size = 0
|
| 119 |
+
active_media_r_size = 0
|
| 120 |
+
early_media_r_url = None
|
| 121 |
+
active_media_r_url = None
|
| 122 |
+
for wav_file in wav_file_list:
|
| 123 |
+
wav_file = Path(wav_file)
|
| 124 |
+
if wav_file.stem.startswith("early_media_r"):
|
| 125 |
+
label = wav_file.parts[-2]
|
| 126 |
+
early_media_r_size = wav_file.stat().st_size
|
| 127 |
+
url_path = f"audio_tag/20251114/{language}/{label}/{wav_file.name}"
|
| 128 |
+
js, message = client.predict(
|
| 129 |
+
filename=handle_file(wav_file.as_posix()),
|
| 130 |
+
url_path=url_path,
|
| 131 |
+
s3_kwargs=json.dumps(s3_kwargs),
|
| 132 |
+
api_name="/when_click_upload_to_s3"
|
| 133 |
+
)
|
| 134 |
+
if message == "success":
|
| 135 |
+
early_media_r_url = f'{s3_kwargs["bucket_endpoint"]}/{url_path}'
|
| 136 |
+
print(f"early_media_r_url: {early_media_r_url}, message: {message}")
|
| 137 |
+
if wav_file.stem.startswith("active_media_r"):
|
| 138 |
+
label = wav_file.parts[-2]
|
| 139 |
+
active_media_r_size = wav_file.stat().st_size
|
| 140 |
+
|
| 141 |
+
url_path = f"audio_tag/20251114/{language}/{label}/{wav_file.name}"
|
| 142 |
+
active_media_r_url, message = client.predict(
|
| 143 |
+
filename=handle_file(wav_file.as_posix()),
|
| 144 |
+
url_path=url_path,
|
| 145 |
+
s3_kwargs=json.dumps(s3_kwargs),
|
| 146 |
+
api_name="/when_click_upload_to_s3"
|
| 147 |
+
)
|
| 148 |
+
if message == "success":
|
| 149 |
+
active_media_r_url = f'{s3_kwargs["bucket_endpoint"]}/{url_path}'
|
| 150 |
+
print(f"active_media_r_url: {active_media_r_url}, message: {message}")
|
| 151 |
+
|
| 152 |
+
simulate_label = get_simulate_label(label)
|
| 153 |
+
|
| 154 |
+
row = {
|
| 155 |
+
"label": label,
|
| 156 |
+
"early_media_r_size": early_media_r_size,
|
| 157 |
+
"active_media_r_size": active_media_r_size,
|
| 158 |
+
|
| 159 |
+
"是否接通": "是" if active_media_r_size != 44 else "否",
|
| 160 |
+
"模拟类型": simulate_label,
|
| 161 |
+
"接通前URL": early_media_r_url,
|
| 162 |
+
"接通后URL": active_media_r_url,
|
| 163 |
+
}
|
| 164 |
+
row_ = json.dumps(row, ensure_ascii=False)
|
| 165 |
+
f.write(f"{row_}\n")
|
| 166 |
+
f.flush()
|
| 167 |
+
# result.append(row)
|
| 168 |
+
row_ = json.dumps(row, ensure_ascii=False, indent=4)
|
| 169 |
+
print(row_)
|
| 170 |
+
|
| 171 |
+
# result = pd.DataFrame(result)
|
| 172 |
+
# result.to_excel(output_file.as_posix(), index=False)
|
| 173 |
+
return
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
if __name__ == "__main__":
|
| 177 |
+
main()
|
examples/make_test_audios/make_test_audios3.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import argparse
|
| 4 |
+
from collections import defaultdict
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
import shutil
|
| 7 |
+
|
| 8 |
+
import pandas as pd
|
| 9 |
+
|
| 10 |
+
from project_settings import project_path
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def get_args():
|
| 14 |
+
parser = argparse.ArgumentParser()
|
| 15 |
+
parser.add_argument(
|
| 16 |
+
"--audio_dir",
|
| 17 |
+
# default=(project_path / "data/analysis/hu-HU").as_posix(),
|
| 18 |
+
default=r"D:\Users\tianx\HuggingSpaces\cc_audio_8\data\make_analysis_excel\download_wav\20251204",
|
| 19 |
+
type=str
|
| 20 |
+
)
|
| 21 |
+
parser.add_argument(
|
| 22 |
+
"--output_dir",
|
| 23 |
+
# default=(project_path / "data/calling/52").as_posix(),
|
| 24 |
+
default=r"D:\Users\tianx\HuggingSpaces\cc_audio_8\data\make_analysis_excel\download_wav\20251204\52",
|
| 25 |
+
type=str
|
| 26 |
+
)
|
| 27 |
+
parser.add_argument(
|
| 28 |
+
"--output_file",
|
| 29 |
+
default=r"D:\Users\tianx\HuggingSpaces\cc_audio_8\data\make_analysis_excel\download_wav\20251204\52\readme.xlsx",
|
| 30 |
+
type=str
|
| 31 |
+
)
|
| 32 |
+
args = parser.parse_args()
|
| 33 |
+
return args
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def main():
|
| 37 |
+
args = get_args()
|
| 38 |
+
audio_dir = Path(args.audio_dir)
|
| 39 |
+
output_dir = Path(args.output_dir)
|
| 40 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
| 41 |
+
output_file = Path(args.output_file)
|
| 42 |
+
output_file.parent.mkdir(parents=True, exist_ok=True)
|
| 43 |
+
|
| 44 |
+
suffix_count = 0
|
| 45 |
+
|
| 46 |
+
call_id_to_wav_file_list = defaultdict(list)
|
| 47 |
+
for filename in audio_dir.glob("*.wav"):
|
| 48 |
+
splits = filename.stem.split("_")
|
| 49 |
+
# print(splits)
|
| 50 |
+
call_id = splits[2]
|
| 51 |
+
# language = splits[4]
|
| 52 |
+
# scene_id = splits[5]
|
| 53 |
+
print(f"call_id: {call_id}")
|
| 54 |
+
call_id_to_wav_file_list[call_id].append(filename)
|
| 55 |
+
print(f"count: {len(call_id_to_wav_file_list)}")
|
| 56 |
+
|
| 57 |
+
result = list()
|
| 58 |
+
|
| 59 |
+
for filename in audio_dir.glob("early_media_*.wav"):
|
| 60 |
+
splits = filename.stem.split("_")
|
| 61 |
+
# print(splits)
|
| 62 |
+
call_id = splits[2]
|
| 63 |
+
print(f"call_id: {call_id}")
|
| 64 |
+
|
| 65 |
+
suffix = f"{suffix_count:03}"
|
| 66 |
+
tgt_dir = output_dir / suffix
|
| 67 |
+
tgt_dir.mkdir(parents=True, exist_ok=True)
|
| 68 |
+
suffix_count += 1
|
| 69 |
+
wav_file_list = call_id_to_wav_file_list[call_id]
|
| 70 |
+
|
| 71 |
+
for wav_file in wav_file_list:
|
| 72 |
+
if wav_file.stem.startswith("active_media"):
|
| 73 |
+
tgt_filename = tgt_dir / f"active_media_{call_id}.wav"
|
| 74 |
+
elif wav_file.stem.startswith("early_media"):
|
| 75 |
+
tgt_filename = tgt_dir / f"early_media_{call_id}.wav"
|
| 76 |
+
elif wav_file.stem.startswith("active_media"):
|
| 77 |
+
continue
|
| 78 |
+
else:
|
| 79 |
+
raise AssertionError
|
| 80 |
+
shutil.copy(
|
| 81 |
+
wav_file.as_posix(),
|
| 82 |
+
tgt_filename.as_posix(),
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
result.append({
|
| 86 |
+
"suffix": suffix,
|
| 87 |
+
"call_id": call_id,
|
| 88 |
+
})
|
| 89 |
+
|
| 90 |
+
result = pd.DataFrame(result)
|
| 91 |
+
result.to_excel(
|
| 92 |
+
output_file.as_posix(),
|
| 93 |
+
index=False
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
return
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
if __name__ == "__main__":
|
| 100 |
+
main()
|
examples/make_test_audios/step_2_make_excel.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import argparse
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
import pandas as pd
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def get_args():
|
| 10 |
+
parser = argparse.ArgumentParser()
|
| 11 |
+
parser.add_argument(
|
| 12 |
+
"--audio_dir",
|
| 13 |
+
default=r"D:\Users\tianx\HuggingSpaces\cc_audio_8\data\make_analysis_excel\download_wav\20251203\52",
|
| 14 |
+
type=str
|
| 15 |
+
)
|
| 16 |
+
parser.add_argument(
|
| 17 |
+
"--output_file",
|
| 18 |
+
default=r"D:\Users\tianx\HuggingSpaces\cc_audio_8\data\make_analysis_excel\download_wav\20251203\52\readme.xlsx",
|
| 19 |
+
type=str
|
| 20 |
+
)
|
| 21 |
+
args = parser.parse_args()
|
| 22 |
+
return args
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def main():
|
| 26 |
+
args = get_args()
|
| 27 |
+
audio_dir = Path(args.audio_dir)
|
| 28 |
+
output_file = Path(args.output_file)
|
| 29 |
+
output_file.parent.mkdir(parents=True, exist_ok=True)
|
| 30 |
+
|
| 31 |
+
result = list()
|
| 32 |
+
for filename in audio_dir.glob("**/early_media_*.wav"):
|
| 33 |
+
suffix = filename.parts[-2]
|
| 34 |
+
splits = filename.stem.split("_")
|
| 35 |
+
call_id = splits[2]
|
| 36 |
+
|
| 37 |
+
result.append({
|
| 38 |
+
"suffix": suffix,
|
| 39 |
+
"call_id": call_id,
|
| 40 |
+
})
|
| 41 |
+
|
| 42 |
+
result = pd.DataFrame(result)
|
| 43 |
+
result.to_excel(
|
| 44 |
+
output_file.as_posix(),
|
| 45 |
+
index=False
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
return
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
if __name__ == "__main__":
|
| 52 |
+
main()
|
requirements.txt
CHANGED
|
@@ -2,3 +2,4 @@ python-dotenv==1.0.1
|
|
| 2 |
pandas
|
| 3 |
openpyxl
|
| 4 |
tqdm
|
|
|
|
|
|
| 2 |
pandas
|
| 3 |
openpyxl
|
| 4 |
tqdm
|
| 5 |
+
gradio_client
|