Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add code * Add code * add changeset * Add code * Add code * prevent resetting source when clearing value * Add code * Add drag-and-drop tests * add changeset * remove console log * Format * Add code * add changeset * Audio components * add changeset * add changeset * Add return type * Add code * promise --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
- Loading branch information
1 parent
6bce259
commit aaa55ce
Showing
16 changed files
with
245 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@gradio/app": patch | ||
"@gradio/audio": patch | ||
"@gradio/tootils": patch | ||
"@gradio/upload": patch | ||
"@gradio/video": patch | ||
"gradio": patch | ||
--- | ||
|
||
fix:Video/Audio fixes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: audio_component_events"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Row():\n", " with gr.Column():\n", " input_video = gr.Audio(label=\"Input Audio\", sources=[\"upload\", \"microphone\"])\n", " with gr.Column():\n", " output_video = gr.Audio(label=\"Output Audio\", sources=[\"upload\", \"microphone\"])\n", " with gr.Column():\n", " num_change = gr.Number(label=\"# Change Events\", value=0)\n", " num_load = gr.Number(label=\"# Upload Events\", value=0)\n", " num_play = gr.Number(label=\"# Play Events\", value=0)\n", " num_pause = gr.Number(label=\"# Pause Events\", value=0)\n", " input_video.upload(lambda s, n: (s, n + 1), [input_video, num_load], [output_video, num_load])\n", " input_video.change(lambda n: n + 1, num_change, num_change)\n", " input_video.play(lambda n: n + 1, num_play, num_play)\n", " input_video.pause(lambda n: n + 1, num_pause, num_pause)\n", " input_video.change(lambda n: n + 1, num_change, num_change)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import gradio as gr | ||
|
||
with gr.Blocks() as demo: | ||
with gr.Row(): | ||
with gr.Column(): | ||
input_video = gr.Audio(label="Input Audio", sources=["upload", "microphone"]) | ||
with gr.Column(): | ||
output_video = gr.Audio(label="Output Audio", sources=["upload", "microphone"]) | ||
with gr.Column(): | ||
num_change = gr.Number(label="# Change Events", value=0) | ||
num_load = gr.Number(label="# Upload Events", value=0) | ||
num_play = gr.Number(label="# Play Events", value=0) | ||
num_pause = gr.Number(label="# Pause Events", value=0) | ||
input_video.upload(lambda s, n: (s, n + 1), [input_video, num_load], [output_video, num_load]) | ||
input_video.change(lambda n: n + 1, num_change, num_change) | ||
input_video.play(lambda n: n + 1, num_play, num_play) | ||
input_video.pause(lambda n: n + 1, num_pause, num_pause) | ||
input_video.change(lambda n: n + 1, num_change, num_change) | ||
|
||
if __name__ == "__main__": | ||
demo.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: video_component_events"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Row():\n", " with gr.Column():\n", " input_video = gr.Video(label=\"Input Video\")\n", " with gr.Column():\n", " output_video = gr.Video(label=\"Output Video\")\n", " with gr.Column():\n", " num_change = gr.Number(label=\"# Change Events\", value=0)\n", " num_load = gr.Number(label=\"# Upload Events\", value=0)\n", " num_play = gr.Number(label=\"# Play Events\", value=0)\n", " num_pause = gr.Number(label=\"# Pause Events\", value=0)\n", " input_video.upload(lambda s, n: (s, n + 1), [input_video, num_load], [output_video, num_load])\n", " input_video.change(lambda n: n + 1, num_change, num_change)\n", " input_video.play(lambda n: n + 1, num_play, num_play)\n", " input_video.pause(lambda n: n + 1, num_pause, num_pause)\n", " input_video.change(lambda n: n + 1, num_change, num_change)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import gradio as gr | ||
|
||
with gr.Blocks() as demo: | ||
with gr.Row(): | ||
with gr.Column(): | ||
input_video = gr.Video(label="Input Video") | ||
with gr.Column(): | ||
output_video = gr.Video(label="Output Video") | ||
with gr.Column(): | ||
num_change = gr.Number(label="# Change Events", value=0) | ||
num_load = gr.Number(label="# Upload Events", value=0) | ||
num_play = gr.Number(label="# Play Events", value=0) | ||
num_pause = gr.Number(label="# Pause Events", value=0) | ||
input_video.upload(lambda s, n: (s, n + 1), [input_video, num_load], [output_video, num_load]) | ||
input_video.change(lambda n: n + 1, num_change, num_change) | ||
input_video.play(lambda n: n + 1, num_play, num_play) | ||
input_video.pause(lambda n: n + 1, num_pause, num_pause) | ||
input_video.change(lambda n: n + 1, num_change, num_change) | ||
|
||
if __name__ == "__main__": | ||
demo.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { test, expect, drag_and_drop_file } from "@gradio/tootils"; | ||
|
||
test("Audio click-to-upload uploads audio successfuly.", async ({ page }) => { | ||
await page | ||
.getByRole("button", { name: "Drop Audio Here - or - Click to Upload" }) | ||
.click(); | ||
const uploader = await page.locator("input[type=file]"); | ||
await Promise.all([ | ||
uploader.setInputFiles(["../../test/test_files/audio_sample.wav"]), | ||
page.waitForResponse("**/upload") | ||
]); | ||
|
||
await expect(page.getByLabel("# Change Events")).toHaveValue("1"); | ||
await expect(page.getByLabel("# Upload Events")).toHaveValue("1"); | ||
|
||
await page.getByLabel("Clear").click(); | ||
await expect(page.getByLabel("# Change Events")).toHaveValue("2"); | ||
await page | ||
.getByRole("button", { name: "Drop Audio Here - or - Click to Upload" }) | ||
.click(); | ||
|
||
await Promise.all([ | ||
uploader.setInputFiles(["../../test/test_files/audio_sample.wav"]), | ||
page.waitForResponse("**/upload") | ||
]); | ||
|
||
await expect(page.getByLabel("# Change Events")).toHaveValue("3"); | ||
await expect(page.getByLabel("# Upload Events")).toHaveValue("2"); | ||
}); | ||
|
||
test("Audio drag-and-drop uploads a file to the server correctly.", async ({ | ||
page | ||
}) => { | ||
await Promise.all([ | ||
drag_and_drop_file( | ||
page, | ||
"input[type=file]", | ||
"../../test/test_files/audio_sample.wav", | ||
"audio_sample.wav", | ||
"audio/wav" | ||
), | ||
page.waitForResponse("**/upload") | ||
]); | ||
await expect(page.getByLabel("# Change Events")).toHaveValue("1"); | ||
await expect(page.getByLabel("# Upload Events")).toHaveValue("1"); | ||
}); | ||
|
||
test("Audio drag-and-drop displays a warning when the file is of the wrong mime type.", async ({ | ||
page | ||
}) => { | ||
await drag_and_drop_file( | ||
page, | ||
"input[type=file]", | ||
"../../test/test_files/audio_sample.wav", | ||
"audio_sample.wav" | ||
); | ||
const toast = page.getByTestId("toast-body"); | ||
expect(toast).toContainText("warning"); | ||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { test, expect, drag_and_drop_file } from "@gradio/tootils"; | ||
|
||
test("Video click-to-upload uploads video successfuly. Clear, play, and pause buttons dispatch events correctly.", async ({ | ||
page | ||
}) => { | ||
await page | ||
.getByRole("button", { name: "Drop Video Here - or - Click to Upload" }) | ||
.click(); | ||
const uploader = await page.locator("input[type=file]"); | ||
await Promise.all([ | ||
uploader.setInputFiles(["./test/files/file_test.ogg"]), | ||
page.waitForResponse("**/upload") | ||
]); | ||
|
||
await expect(page.getByLabel("# Change Events")).toHaveValue("1"); | ||
await expect(page.getByLabel("# Upload Events")).toHaveValue("1"); | ||
|
||
await page.getByLabel("play-pause-replay-button").nth(0).click(); | ||
await page.getByLabel("play-pause-replay-button").nth(0).click(); | ||
await expect(page.getByLabel("# Play Events")).toHaveValue("1"); | ||
await expect(page.getByLabel("# Pause Events")).toHaveValue("1"); | ||
|
||
await page.getByLabel("Clear").click(); | ||
await expect(page.getByLabel("# Change Events")).toHaveValue("2"); | ||
await page | ||
.getByRole("button", { name: "Drop Video Here - or - Click to Upload" }) | ||
.click(); | ||
|
||
await Promise.all([ | ||
uploader.setInputFiles(["./test/files/file_test.ogg"]), | ||
page.waitForResponse("**/upload") | ||
]); | ||
|
||
await expect(page.getByLabel("# Change Events")).toHaveValue("3"); | ||
await expect(page.getByLabel("# Upload Events")).toHaveValue("2"); | ||
|
||
await page.getByLabel("play-pause-replay-button").first().click(); | ||
await page.getByLabel("play-pause-replay-button").first().click(); | ||
await expect(page.getByLabel("# Play Events")).toHaveValue("2"); | ||
await expect(page.getByLabel("# Pause Events")).toHaveValue("2"); | ||
}); | ||
|
||
test("Video drag-and-drop uploads a file to the server correctly.", async ({ | ||
page | ||
}) => { | ||
await drag_and_drop_file( | ||
page, | ||
"input[type=file]", | ||
"./test/files/file_test.ogg", | ||
"file_test.ogg", | ||
"video/*" | ||
); | ||
await page.waitForResponse("**/upload"); | ||
await expect(page.getByLabel("# Change Events")).toHaveValue("1"); | ||
await expect(page.getByLabel("# Upload Events")).toHaveValue("1"); | ||
}); | ||
|
||
test("Video drag-and-drop displays a warning when the file is of the wrong mime type.", async ({ | ||
page | ||
}) => { | ||
await drag_and_drop_file( | ||
page, | ||
"input[type=file]", | ||
"./test/files/file_test.ogg", | ||
"file_test.ogg" | ||
); | ||
const toast = page.getByTestId("toast-body"); | ||
expect(toast).toContainText("warning"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters