Disable compression by default, too slow
Topic: disable_compression
This commit is contained in:
parent
266af6b3e0
commit
f7288f8cd3
|
@ -108,9 +108,9 @@ Execute:
|
||||||
python -m riffusion.cli image-to-audio --image spectrogram_image.png --audio clip.wav
|
python -m riffusion.cli image-to-audio --image spectrogram_image.png --audio clip.wav
|
||||||
```
|
```
|
||||||
|
|
||||||
## Streamlit playground
|
## Riffusion Playground
|
||||||
|
|
||||||
Riffusion also has a streamlit app for interactive use and exploration.
|
Riffusion also has a [streamlit](https://streamlit.io/) app for interactive use and exploration.
|
||||||
This app is called the Riffusion Playground.
|
This app is called the Riffusion Playground.
|
||||||
|
|
||||||
Run with:
|
Run with:
|
||||||
|
|
|
@ -155,8 +155,9 @@ def compute_request(
|
||||||
)
|
)
|
||||||
|
|
||||||
# Reconstruct audio from the image
|
# Reconstruct audio from the image
|
||||||
# TODO(hayk): It may help performance to cache this object
|
# TODO(hayk): It may help performance a bit to cache this object
|
||||||
converter = SpectrogramImageConverter(params=params, device=str(pipeline.device))
|
converter = SpectrogramImageConverter(params=params, device=str(pipeline.device))
|
||||||
|
|
||||||
segment = converter.audio_from_spectrogram_image(
|
segment = converter.audio_from_spectrogram_image(
|
||||||
image,
|
image,
|
||||||
apply_filters=True,
|
apply_filters=True,
|
||||||
|
|
|
@ -155,7 +155,10 @@ class SpectrogramConverter:
|
||||||
|
|
||||||
# Optionally apply post-processing filters
|
# Optionally apply post-processing filters
|
||||||
if apply_filters:
|
if apply_filters:
|
||||||
segment = audio_util.apply_filters(segment)
|
segment = audio_util.apply_filters(
|
||||||
|
segment,
|
||||||
|
compression=False,
|
||||||
|
)
|
||||||
|
|
||||||
return segment
|
return segment
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ def audio_from_waveform(
|
||||||
return pydub.AudioSegment.from_wav(wav_bytes)
|
return pydub.AudioSegment.from_wav(wav_bytes)
|
||||||
|
|
||||||
|
|
||||||
def apply_filters(segment: pydub.AudioSegment) -> pydub.AudioSegment:
|
def apply_filters(segment: pydub.AudioSegment, compression: bool = False) -> pydub.AudioSegment:
|
||||||
"""
|
"""
|
||||||
Apply post-processing filters to the audio segment to compress it and
|
Apply post-processing filters to the audio segment to compress it and
|
||||||
keep at a -10 dBFS level.
|
keep at a -10 dBFS level.
|
||||||
|
@ -40,6 +40,7 @@ def apply_filters(segment: pydub.AudioSegment) -> pydub.AudioSegment:
|
||||||
# TODO(hayk): Come up with a principled strategy for these filters and experiment end-to-end.
|
# TODO(hayk): Come up with a principled strategy for these filters and experiment end-to-end.
|
||||||
# TODO(hayk): Is this going to make audio unbalanced between sequential clips?
|
# TODO(hayk): Is this going to make audio unbalanced between sequential clips?
|
||||||
|
|
||||||
|
if compression:
|
||||||
segment = pydub.effects.normalize(
|
segment = pydub.effects.normalize(
|
||||||
segment,
|
segment,
|
||||||
headroom=0.1,
|
headroom=0.1,
|
||||||
|
@ -47,6 +48,7 @@ def apply_filters(segment: pydub.AudioSegment) -> pydub.AudioSegment:
|
||||||
|
|
||||||
segment = segment.apply_gain(-10 - segment.dBFS)
|
segment = segment.apply_gain(-10 - segment.dBFS)
|
||||||
|
|
||||||
|
# TODO(hayk): This is quite slow, ~1.7 seconds on a beefy CPU
|
||||||
segment = pydub.effects.compress_dynamic_range(
|
segment = pydub.effects.compress_dynamic_range(
|
||||||
segment,
|
segment,
|
||||||
threshold=-20.0,
|
threshold=-20.0,
|
||||||
|
|
Loading…
Reference in New Issue