Skip to content

Commit

Permalink
Less noise on console logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jordimas committed Sep 15, 2024
1 parent cf41bff commit 40284f0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
9 changes: 6 additions & 3 deletions open_dubbing/dubbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def pyannote_pipeline(self) -> Pipeline:

def _verify_api_access(self) -> None:
"""Verifies access to all the required APIs."""
logging.info("Verifying access to PyAnnote from HuggingFace.")
logging.debug("Verifying access to PyAnnote from HuggingFace.")
if not self.pyannote_pipeline:
raise PyAnnoteAccessError(
"No access to HuggingFace. Make sure you passed the correct API token"
Expand All @@ -178,7 +178,7 @@ def _verify_api_access(self) -> None:
" diarization model"
" (https://huggingface.co/pyannote/speaker-diarization-3.1)."
)
logging.info("Access to PyAnnote from HuggingFace verified.")
logging.debug("Access to PyAnnote from HuggingFace verified.")

def run_preprocessing(self) -> None:
"""Splits audio/video, applies DEMUCS, and segments audio into utterances with PyAnnote.
Expand Down Expand Up @@ -361,7 +361,7 @@ def run_save_utterance_metadata(self) -> None:
os.fsync(temporary_file.fileno())
shutil.copy(temporary_file.name, utterance_metadata_file)
os.remove(temporary_file.name)
logging.info(
logging.debug(
"Utterance metadata saved successfully to"
f" '{utterance_metadata_file}'"
)
Expand All @@ -374,7 +374,10 @@ def dub(self) -> PostprocessingArtifacts:
self._verify_api_access()
logging.info("Dubbing process starting...")
start_time = time.time()

task_start_time = time.time()
self.run_preprocessing()
self.log_debug_task("Preprocessing completed", task_start_time)

logging.info("Speech to text...")
task_start_time = time.time()
Expand Down
2 changes: 1 addition & 1 deletion open_dubbing/speech_to_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def diarize_speakers(
_tuple = ("speaker_01", "Male")
r.append(_tuple)

logging.info(f"text_to_speech.diarize_speakers. Returns: {r}")
logging.debug(f"text_to_speech.diarize_speakers. Returns: {r}")
return r

def add_speaker_info(
Expand Down
6 changes: 3 additions & 3 deletions open_dubbing/text_to_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def assign_voices(
) -> Mapping[str, str | None]:

voice_assignment = {"speaker_01": "ona"}
logging.info(f"TextToSpeech.assign_voices. Returns: {voice_assignment}")
logging.debug(f"TextToSpeech.assign_voices. Returns: {voice_assignment}")
return voice_assignment

def _convert_to_mp3(self, input_file, output_mp3):
Expand Down Expand Up @@ -164,12 +164,12 @@ def _adjust_audio_speed(
crossfade = max(1, chunk_size // 2)
MAX_SPEED = 1.3
if speed > MAX_SPEED:
logging.info(
logging.debug(
f"TextToSpeech.adjust_audio_speed: Reduced speed from {speed} to {MAX_SPEED}"
)
speed = MAX_SPEED

logging.info(
logging.debug(
f"TextToSpeech.adjust_audio_speed: dubbed_audio: {dubbed_file}, speed: {speed}, chunk_size: {chunk_size}, crossfade: {crossfade}"
)
output_audio = speedup(
Expand Down
2 changes: 1 addition & 1 deletion open_dubbing/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def generate_script(self, *, utterance_metadata, key: str = "text") -> str:
trimmed_lines = [
item[key].strip() if item[key] else "" for item in utterance_metadata
]
logging.info(f"translation.generate_script. Input: {trimmed_lines}")
logging.debug(f"translation.generate_script. Input: {trimmed_lines}")
r = _BREAK_MARKER + _BREAK_MARKER.join(trimmed_lines) + _BREAK_MARKER
logging.debug(f"translation.generate_script. Returns: {r}")
return r
Expand Down
1 change: 1 addition & 0 deletions r.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ for tts in "${tts_list[@]}"; do
--target_language="$language" \
--tts="$tts" \
--device=cpu
echo ""
done
done
done
Expand Down

0 comments on commit 40284f0

Please sign in to comment.