Support audio data in np.int8 format in the gr.Audio component (#7112)

* fix#7099

Fix for Audio data cannot be converted automatically from int8 to 16-bit int format

* add changeset

* add changeset

* fix'

* processing

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
Ram-Pasupula 2024-01-22 18:23:52 -05:00 committed by GitHub
parent 94aa271ab1
commit 217bfe39ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": patch
---
fix:Support audio data in `np.int8` format in the `gr.Audio` component

View File

@ -343,7 +343,7 @@ def convert_to_16_bit_wav(data):
data = data.astype(np.int16)
elif data.dtype == np.int32:
warnings.warn(warning.format(data.dtype))
data = data / 65538
data = data / 65536
data = data.astype(np.int16)
elif data.dtype == np.int16:
pass
@ -355,6 +355,10 @@ def convert_to_16_bit_wav(data):
warnings.warn(warning.format(data.dtype))
data = data * 257 - 32768
data = data.astype(np.int16)
elif data.dtype == np.int8:
warnings.warn(warning.format(data.dtype))
data = data * 256
data = data.astype(np.int16)
else:
raise ValueError(
"Audio data cannot be converted automatically from "