mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
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:
parent
94aa271ab1
commit
217bfe39ca
5
.changeset/big-bananas-sell.md
Normal file
5
.changeset/big-bananas-sell.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Support audio data in `np.int8` format in the `gr.Audio` component
|
@ -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 "
|
||||
|
Loading…
x
Reference in New Issue
Block a user