Skip to content

Commit

Permalink
fix: Fix to a problem when inserting no dubbing audio chunks into the…
Browse files Browse the repository at this point in the history
… dubbed audio track.

Change-Id: Ica1483dbbf4696dc7a7571e13383e7b9dfb3c595
  • Loading branch information
Kacper Krasowiak committed Oct 24, 2024
1 parent fe912dd commit a6a1aa9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ariel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.

"""Ariel library for for end-to-end video ad dubbing using AI."""
__version__ = "0.0.15"
__version__ = "0.0.16"
15 changes: 9 additions & 6 deletions ariel/audio_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,16 @@ def insert_audio_at_timestamps(
output_audio = AudioSegment.silent(duration=total_duration * 1000)
meter = Meter(rate=_DEFAULT_RATE)
for item in utterance_metadata:
audio_chunk = AudioSegment.from_mp3(item["dubbed_path"])
samples = np.array(audio_chunk.get_array_of_samples())
samples = samples.astype(np.float32) / np.iinfo(samples.dtype).max
loudness = meter.integrated_loudness(samples)
loudness_difference = _TARGET_LUFS - loudness
audio_chunk = audio_chunk.apply_gain(loudness_difference)
start_time = int(item["start"] * 1000)
if not item["for_dubbing"]:
audio_chunk = AudioSegment.from_mp3(item["path"])
else:
audio_chunk = AudioSegment.from_mp3(item["dubbed_path"])
samples = np.array(audio_chunk.get_array_of_samples())
samples = samples.astype(np.float32) / np.iinfo(samples.dtype).max
loudness = meter.integrated_loudness(samples)
loudness_difference = _TARGET_LUFS - loudness
audio_chunk = audio_chunk.apply_gain(loudness_difference)
output_audio = output_audio.overlay(
audio_chunk, position=start_time, loop=False
)
Expand Down
2 changes: 1 addition & 1 deletion ariel/colab_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def copy_output_to_google_drive(
destination_path = os.path.join(destination_dir, filename)
if not tf.io.gfile.exists(destination_path):
tf.io.gfile.copy(source_path, destination_path, overwrite=True)
print(f"The output is now saved under: {destination_dir}")
print(f"The output is saved in: {destination_dir}")


def get_google_sheet_as_dataframe(sheet_link: str) -> pd.DataFrame:
Expand Down
1 change: 1 addition & 0 deletions ariel/dubbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,7 @@ def _prompt_for_dubbed_utterances_verification(self) -> None:
).lower()
if verify_again_choice == "yes":
self._verify_and_redub_utterances()
clear_output(wait=True)
self._prompt_for_dubbed_utterances_verification()
break
elif verify_again_choice == "no":
Expand Down

0 comments on commit a6a1aa9

Please sign in to comment.