Skip to content

Commit

Permalink
Add option to save emo
Browse files Browse the repository at this point in the history
  • Loading branch information
AnyaCoder committed Aug 19, 2024
1 parent 74bd9e7 commit 89df0ea
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tools/sensevoice/fun_asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def convert_video_to_audio(video_path: Path, audio_dir: Path):
)
@click.option("--punc/--no-punc", default=False)
@click.option("--denoise/--no-denoise", default=False)
@click.option("--save_emo/--no_save_emo", default=False)
def main(
audio_dir: str,
save_dir: str,
Expand All @@ -152,6 +153,7 @@ def main(
max_single_segment_time: int,
punc: bool,
denoise: bool,
save_emo: bool,
):

audios_path = Path(audio_dir)
Expand Down Expand Up @@ -267,13 +269,14 @@ def main(
) as f:
f.write(text)

emo_save_path = save_path / rel_path.parent / f"{file_stem}_{i:03d}.emo"
with open(
emo_save_path,
"w",
encoding="utf-8",
) as f:
f.write(emo)
if save_emo:
emo_save_path = save_path / rel_path.parent / f"{file_stem}_{i:03d}.emo"
with open(
emo_save_path,
"w",
encoding="utf-8",
) as f:
f.write(emo)

if audios_path.resolve() == save_path.resolve():
file_path.unlink()
Expand Down

0 comments on commit 89df0ea

Please sign in to comment.