mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
fixed crash if audio volume has wrong type
This commit is contained in:
parent
1c00fcd13b
commit
65cab5fa3c
1 changed files with 7 additions and 0 deletions
|
@ -1014,6 +1014,13 @@ def set_audio_volume(datalist, volume: float) -> np.int16:
|
||||||
:return: Scaled audio samples
|
:return: Scaled audio samples
|
||||||
:rtype: np.int16
|
:rtype: np.int16
|
||||||
"""
|
"""
|
||||||
|
# make sure we have float as data type to avoid crash
|
||||||
|
try:
|
||||||
|
volume = float(volume)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[MDM] changing audio volume failed with error: {e}")
|
||||||
|
volume = 100.0
|
||||||
|
|
||||||
# Clip volume provided to acceptable values
|
# Clip volume provided to acceptable values
|
||||||
volume = np.clip(volume, 0, 200) # limit to max value of 255
|
volume = np.clip(volume, 0, 200) # limit to max value of 255
|
||||||
# Scale samples by the ratio of volume / 100.0
|
# Scale samples by the ratio of volume / 100.0
|
||||||
|
|
Loading…
Reference in a new issue