mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-22 05:09:05 +00:00
fix: waveform can generate NaN in json database (#481)
* refactor: fixes transcript duration type, NaN in waveform, and prepare for postgres migration * fix: ensure we don't have NaN in waveform * fix: missing assertionerror Co-authored-by: pr-agent-monadical[bot] <198624643+pr-agent-monadical[bot]@users.noreply.github.com> * fix: potential empty array --------- Co-authored-by: pr-agent-monadical[bot] <198624643+pr-agent-monadical[bot]@users.noreply.github.com>
This commit is contained in:
@@ -57,7 +57,10 @@ def get_audio_waveform(path: Path | str, segments_count: int = 256) -> list[int]
|
||||
|
||||
# number of decimals to use when rounding the peak value
|
||||
digits = 2
|
||||
volumes = np.round(volumes / volumes.max(), digits)
|
||||
if len(volumes) > 0 and volumes.max() > 0:
|
||||
volumes = np.round(volumes / volumes.max(), digits)
|
||||
else:
|
||||
volumes = np.zeros_like(volumes) if len(volumes) > 0 else np.array([])
|
||||
|
||||
return volumes.tolist()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user