Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio updated via _js breaks preprocess. #4958

Open
1 task done
Tracked by #5321
Sreerag-ibtl opened this issue Jul 18, 2023 · 0 comments
Open
1 task done
Tracked by #5321

Audio updated via _js breaks preprocess. #4958

Sreerag-ibtl opened this issue Jul 18, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Sreerag-ibtl
Copy link

Sreerag-ibtl commented Jul 18, 2023

Describe the bug

I am passing a javascript function to _js which returns an audio URL. This is expected to update the audio which is the case. But this audio component, when used as input in the button click event, it throws an error.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio

audio_url = "http://codeskulptor-demos.commondatastorage.googleapis.com/GalaxyInvaders/alien_hit.wav"

with gradio.Blocks() as blocks:
  audio = gradio.Audio(value=audio_url, type='filepath',)
  output = gradio.Audio()
  button = gradio.Button(value='Button')
  submit = gradio.Button(value='Submit')

  # First click here.
  button.click(None, None, [audio], _js="""function () {return 'http://codeskulptor-demos.commondatastorage.googleapis.com/GalaxyInvaders/alien_hit.wav'}""")

  # Then here.
  submit.click(lambda x: x, [audio], [output])

blocks.launch(debug=True)

Screenshot

No response

Logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/gradio/routes.py", line 439, in run_predict
    output = await app.get_blocks().process_api(
  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1387, in process_api
    inputs = self.preprocess_data(fn_index, inputs, state)
  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1230, in preprocess_data
    processed_input.append(block.preprocess(inputs[i]))
  File "/usr/local/lib/python3.10/dist-packages/gradio/components/audio.py", line 191, in preprocess
    x["name"],
TypeError: string indices must be integers

System Info

1. Gradio: 3.37.0
2. Colab, Ubuntu 22.04
3. Browser: Firefox

Severity

Blocking usage of gradio

@Sreerag-ibtl Sreerag-ibtl added the bug Something isn't working label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant