Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- Dockerfile +16 -0
- README.md +12 -5
- __init__.py +0 -0
- __pycache__/__init__.cpython-311.pyc +0 -0
- __pycache__/app.cpython-311.pyc +0 -0
- app.py +18 -0
- bubbly-trim.mp3 +0 -0
- css.css +157 -0
- freeman.jpg +0 -0
- requirements.txt +1 -0
- space.py +154 -0
- src/.DS_Store +0 -0
- src/.gitignore +9 -0
- src/README.md +390 -0
- src/backend/gradio_unifiedaudio/__init__.py +4 -0
- src/backend/gradio_unifiedaudio/templates/component/__vite-browser-external-2447137e.js +4 -0
- src/backend/gradio_unifiedaudio/templates/component/index-c48f56d2.js +0 -0
- src/backend/gradio_unifiedaudio/templates/component/index.js +8 -0
- src/backend/gradio_unifiedaudio/templates/component/module-2c3384e6.js +64 -0
- src/backend/gradio_unifiedaudio/templates/component/module-ae1e1517.js +0 -0
- src/backend/gradio_unifiedaudio/templates/component/module-ef7e7a9a.js +20 -0
- src/backend/gradio_unifiedaudio/templates/component/style.css +1 -0
- src/backend/gradio_unifiedaudio/templates/component/wrapper-98f94c21-f7f71f53.js +2449 -0
- src/backend/gradio_unifiedaudio/templates/example/index.js +88 -0
- src/backend/gradio_unifiedaudio/templates/example/style.css +1 -0
- src/backend/gradio_unifiedaudio/unifiedaudio.py +288 -0
- src/backend/gradio_unifiedaudio/unifiedaudio.pyi +750 -0
- src/demo/__init__.py +0 -0
- src/demo/app.py +18 -0
- src/demo/bubbly-trim.mp3 +0 -0
- src/demo/css.css +157 -0
- src/demo/freeman.jpg +0 -0
- src/demo/space.py +154 -0
- src/frontend/Example.svelte +19 -0
- src/frontend/Index.svelte +166 -0
- src/frontend/index.ts +7 -0
- src/frontend/interactive/InteractiveAudio.svelte +142 -0
- src/frontend/package-lock.json +1306 -0
- src/frontend/package.json +32 -0
- src/frontend/player/AudioPlayer.svelte +198 -0
- src/frontend/pnpm-lock.yaml +961 -0
- src/frontend/recorder/AudioRecorder.svelte +213 -0
- src/frontend/shared/WaveformControls.svelte +342 -0
- src/frontend/shared/WaveformRecordControls.svelte +145 -0
- src/frontend/shared/audioBufferToWav.ts +56 -0
- src/frontend/shared/types.ts +6 -0
- src/frontend/shared/utils.ts +91 -0
- src/frontend/static/StaticAudio.svelte +242 -0
- src/frontend/streaming/StreamAudio.svelte +132 -0
- src/pyproject.toml +49 -0
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
FROM python:3.9
|
3 |
+
|
4 |
+
WORKDIR /code
|
5 |
+
|
6 |
+
COPY --link --chown=1000 . .
|
7 |
+
|
8 |
+
RUN mkdir -p /tmp/cache/
|
9 |
+
RUN chmod a+rwx -R /tmp/cache/
|
10 |
+
ENV TRANSFORMERS_CACHE=/tmp/cache/
|
11 |
+
|
12 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
13 |
+
|
14 |
+
ENV PYTHONUNBUFFERED=1 GRADIO_ALLOW_FLAGGING=never GRADIO_NUM_PORTS=1 GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 SYSTEM=spaces
|
15 |
+
|
16 |
+
CMD ["python", "space.py"]
|
README.md
CHANGED
@@ -1,10 +1,17 @@
|
|
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: docker
|
7 |
pinned: false
|
|
|
8 |
---
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
---
|
3 |
+
tags: [gradio-custom-component,machine learning,reproducibility,visualization,gradio,gradio-template-Audio]
|
4 |
+
title: gradio_unifiedaudio V0.0.2
|
5 |
+
colorFrom: pink
|
6 |
+
colorTo: blue
|
7 |
sdk: docker
|
8 |
pinned: false
|
9 |
+
license: apache-2.0
|
10 |
---
|
11 |
|
12 |
+
|
13 |
+
# Name: gradio_unifiedaudio
|
14 |
+
|
15 |
+
Description: Python library for easily interacting with trained machine learning models
|
16 |
+
|
17 |
+
Install with: pip install gradio_unifiedaudio
|
__init__.py
ADDED
File without changes
|
__pycache__/__init__.cpython-311.pyc
ADDED
Binary file (188 Bytes). View file
|
|
__pycache__/app.cpython-311.pyc
ADDED
Binary file (1.2 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_unifiedaudio import UnifiedAudio
|
4 |
+
from os.path import abspath, join, pardir
|
5 |
+
from pathlib import Path
|
6 |
+
|
7 |
+
example = UnifiedAudio().example_inputs()
|
8 |
+
dir_ = Path(__file__).parent
|
9 |
+
|
10 |
+
def test_mic(audio):
|
11 |
+
return UnifiedAudio(value=audio)
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
mic = UnifiedAudio(sources="microphone")
|
15 |
+
mic.change(test_mic, mic, mic)
|
16 |
+
|
17 |
+
if __name__ == '__main__':
|
18 |
+
demo.launch()
|
bubbly-trim.mp3
ADDED
Binary file (804 kB). View file
|
|
css.css
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
html {
|
2 |
+
font-family: Inter;
|
3 |
+
font-size: 16px;
|
4 |
+
font-weight: 400;
|
5 |
+
line-height: 1.5;
|
6 |
+
-webkit-text-size-adjust: 100%;
|
7 |
+
background: #fff;
|
8 |
+
color: #323232;
|
9 |
+
-webkit-font-smoothing: antialiased;
|
10 |
+
-moz-osx-font-smoothing: grayscale;
|
11 |
+
text-rendering: optimizeLegibility;
|
12 |
+
}
|
13 |
+
|
14 |
+
:root {
|
15 |
+
--space: 1;
|
16 |
+
--vspace: calc(var(--space) * 1rem);
|
17 |
+
--vspace-0: calc(3 * var(--space) * 1rem);
|
18 |
+
--vspace-1: calc(2 * var(--space) * 1rem);
|
19 |
+
--vspace-2: calc(1.5 * var(--space) * 1rem);
|
20 |
+
--vspace-3: calc(0.5 * var(--space) * 1rem);
|
21 |
+
}
|
22 |
+
|
23 |
+
.app {
|
24 |
+
max-width: 748px !important;
|
25 |
+
}
|
26 |
+
|
27 |
+
.prose p {
|
28 |
+
margin: var(--vspace) 0;
|
29 |
+
line-height: var(--vspace * 2);
|
30 |
+
font-size: 1rem;
|
31 |
+
}
|
32 |
+
|
33 |
+
code {
|
34 |
+
font-family: "Inconsolata", sans-serif;
|
35 |
+
font-size: 16px;
|
36 |
+
}
|
37 |
+
|
38 |
+
h1,
|
39 |
+
h1 code {
|
40 |
+
font-weight: 400;
|
41 |
+
line-height: calc(2.5 / var(--space) * var(--vspace));
|
42 |
+
}
|
43 |
+
|
44 |
+
h1 code {
|
45 |
+
background: none;
|
46 |
+
border: none;
|
47 |
+
letter-spacing: 0.05em;
|
48 |
+
padding-bottom: 5px;
|
49 |
+
position: relative;
|
50 |
+
padding: 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
h2 {
|
54 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
55 |
+
line-height: 1em;
|
56 |
+
}
|
57 |
+
|
58 |
+
h3,
|
59 |
+
h3 code {
|
60 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
61 |
+
line-height: 1em;
|
62 |
+
}
|
63 |
+
|
64 |
+
h4,
|
65 |
+
h5,
|
66 |
+
h6 {
|
67 |
+
margin: var(--vspace-3) 0 var(--vspace-3) 0;
|
68 |
+
line-height: var(--vspace);
|
69 |
+
}
|
70 |
+
|
71 |
+
.bigtitle,
|
72 |
+
h1,
|
73 |
+
h1 code {
|
74 |
+
font-size: calc(8px * 4.5);
|
75 |
+
word-break: break-word;
|
76 |
+
}
|
77 |
+
|
78 |
+
.title,
|
79 |
+
h2,
|
80 |
+
h2 code {
|
81 |
+
font-size: calc(8px * 3.375);
|
82 |
+
font-weight: lighter;
|
83 |
+
word-break: break-word;
|
84 |
+
border: none;
|
85 |
+
background: none;
|
86 |
+
}
|
87 |
+
|
88 |
+
.subheading1,
|
89 |
+
h3,
|
90 |
+
h3 code {
|
91 |
+
font-size: calc(8px * 1.8);
|
92 |
+
font-weight: 600;
|
93 |
+
border: none;
|
94 |
+
background: none;
|
95 |
+
letter-spacing: 0.1em;
|
96 |
+
text-transform: uppercase;
|
97 |
+
}
|
98 |
+
|
99 |
+
h2 code {
|
100 |
+
padding: 0;
|
101 |
+
position: relative;
|
102 |
+
letter-spacing: 0.05em;
|
103 |
+
}
|
104 |
+
|
105 |
+
blockquote {
|
106 |
+
font-size: calc(8px * 1.1667);
|
107 |
+
font-style: italic;
|
108 |
+
line-height: calc(1.1667 * var(--vspace));
|
109 |
+
margin: var(--vspace-2) var(--vspace-2);
|
110 |
+
}
|
111 |
+
|
112 |
+
.subheading2,
|
113 |
+
h4 {
|
114 |
+
font-size: calc(8px * 1.4292);
|
115 |
+
text-transform: uppercase;
|
116 |
+
font-weight: 600;
|
117 |
+
}
|
118 |
+
|
119 |
+
.subheading3,
|
120 |
+
h5 {
|
121 |
+
font-size: calc(8px * 1.2917);
|
122 |
+
line-height: calc(1.2917 * var(--vspace));
|
123 |
+
|
124 |
+
font-weight: lighter;
|
125 |
+
text-transform: uppercase;
|
126 |
+
letter-spacing: 0.15em;
|
127 |
+
}
|
128 |
+
|
129 |
+
h6 {
|
130 |
+
font-size: calc(8px * 1.1667);
|
131 |
+
font-size: 1.1667em;
|
132 |
+
font-weight: normal;
|
133 |
+
font-style: italic;
|
134 |
+
font-family: "le-monde-livre-classic-byol", serif !important;
|
135 |
+
letter-spacing: 0px !important;
|
136 |
+
}
|
137 |
+
|
138 |
+
#start .md > *:first-child {
|
139 |
+
margin-top: 0;
|
140 |
+
}
|
141 |
+
|
142 |
+
h2 + h3 {
|
143 |
+
margin-top: 0;
|
144 |
+
}
|
145 |
+
|
146 |
+
.md hr {
|
147 |
+
border: none;
|
148 |
+
border-top: 1px solid var(--block-border-color);
|
149 |
+
margin: var(--vspace-2) 0 var(--vspace-2) 0;
|
150 |
+
}
|
151 |
+
.prose ul {
|
152 |
+
margin: var(--vspace-2) 0 var(--vspace-1) 0;
|
153 |
+
}
|
154 |
+
|
155 |
+
.gap {
|
156 |
+
gap: 0;
|
157 |
+
}
|
freeman.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio_unifiedaudio-0.0.2-py3-none-any.whl
|
space.py
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from app import demo as app
|
4 |
+
import os
|
5 |
+
|
6 |
+
_docs = {'UnifiedAudio': {'description': 'Creates an audio component that can be used to upload/record audio (as an input) or display audio (as an output).', 'members': {'__init__': {'value': {'type': 'str\n | pathlib.Path\n | tuple[int, numpy.ndarray]\n | Callable\n | None', 'default': 'None', 'description': 'A path, URL, or [sample_rate, numpy array] tuple (sample rate in Hz, audio data as a float or int numpy array) for the default value that UnifiedAudio component is going to take. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'image': {'type': 'str | None', 'default': 'None', 'description': 'A path or URL to an image to display above the audio component. If None, no image will be displayed.'}, 'sources': {'type': 'list["upload" | "microphone"] | None', 'default': 'None', 'description': 'A list of sources permitted for audio. "upload" creates a box where user can drop an audio file, "microphone" creates a microphone input. The first element in the list will be used as the default source. If None, defaults to ["upload", "microphone"], or ["microphone"] if `streaming` is True.'}, 'type': {'type': '"numpy" | "filepath"', 'default': '"numpy"', 'description': 'The format the audio file is converted to before being passed into the prediction function. "numpy" converts the audio to a tuple consisting of: (int sample rate, numpy.array for the data), "filepath" passes a str path to a temporary file containing the audio.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will allow users to upload and edit a audio file; if False, can only be used to play audio. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'streaming': {'type': 'bool', 'default': 'False', 'description': 'If set to True when used in a `live` interface as an input, will automatically stream webcam feed. When used set as an output, takes audio chunks yield from the backend and combines them into one streaming audio output.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'format': {'type': '"wav" | "mp3"', 'default': '"wav"', 'description': 'The file format to save audio files. Either \'wav\' or \'mp3\'. wav files are lossless but will tend to be larger files. mp3 files tend to be smaller. Default is wav. Applies both when this component is used as an input (when `type` is "format") and when this component is used as an output.'}, 'autoplay': {'type': 'bool', 'default': 'False', 'description': 'Whether to automatically play the audio when the component is used as an output. Note: browsers will not autoplay audio files if the user has not interacted with the page yet.'}, 'show_share_button': {'type': 'bool | None', 'default': 'None', 'description': 'If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.'}, 'min_length': {'type': 'int | None', 'default': 'None', 'description': 'The minimum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no minimum length.'}, 'max_length': {'type': 'int | None', 'default': 'None', 'description': 'The maximum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no maximum length.'}, 'waveform_options': {'type': 'WaveformOptions | None', 'default': 'None', 'description': 'A dictionary of options for the waveform display. Options include: waveform_color (str), waveform_progress_color (str), show_controls (bool), skip_length (int). Default is None, which uses the default values for these options.'}}, 'postprocess': {'value': {'type': 'tuple[int, numpy.ndarray]\n | str\n | pathlib.Path\n | bytes\n | None', 'description': 'audio data in either of the following formats: a tuple of (sample_rate, data), or a string filepath or URL to an audio file, or None.'}}, 'preprocess': {'return': {'type': 'tuple[int, numpy.ndarray] | str | None', 'description': None}, 'value': None}}, 'events': {'stream': {'type': None, 'default': None, 'description': 'This listener is triggered when the user streams the UnifiedAudio.'}, 'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the UnifiedAudio changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'clear': {'type': None, 'default': None, 'description': 'This listener is triggered when the user clears the UnifiedAudio using the X button for the component.'}, 'play': {'type': None, 'default': None, 'description': 'This listener is triggered when the user plays the media in the UnifiedAudio.'}, 'pause': {'type': None, 'default': None, 'description': 'This listener is triggered when the media in the UnifiedAudio stops for any reason.'}, 'stop': {'type': None, 'default': None, 'description': 'This listener is triggered when the user reaches the end of the media playing in the UnifiedAudio.'}, 'start_recording': {'type': None, 'default': None, 'description': 'This listener is triggered when the user starts recording with the UnifiedAudio.'}, 'pause_recording': {'type': None, 'default': None, 'description': 'This listener is triggered when the user pauses recording with the UnifiedAudio.'}, 'stop_recording': {'type': None, 'default': None, 'description': 'This listener is triggered when the user stops recording with the UnifiedAudio.'}, 'upload': {'type': None, 'default': None, 'description': 'This listener is triggered when the user uploads a file into the UnifiedAudio.'}}}, '__meta__': {'additional_interfaces': {'WaveformOptions': {'source': 'class WaveformOptions(TypedDict, total=False):\n waveform_color: str\n waveform_progress_color: str\n show_controls: bool\n skip_length: int'}}, 'user_fn_refs': {'UnifiedAudio': []}}}
|
7 |
+
|
8 |
+
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
+
|
10 |
+
with gr.Blocks(
|
11 |
+
css=abs_path,
|
12 |
+
theme=gr.themes.Default(
|
13 |
+
font_mono=[
|
14 |
+
gr.themes.GoogleFont("Inconsolata"),
|
15 |
+
"monospace",
|
16 |
+
],
|
17 |
+
),
|
18 |
+
) as demo:
|
19 |
+
gr.Markdown(
|
20 |
+
"""
|
21 |
+
# `gradio_unifiedaudio`
|
22 |
+
|
23 |
+
<div style="display: flex; gap: 7px;">
|
24 |
+
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.2%20-%20orange">
|
25 |
+
</div>
|
26 |
+
|
27 |
+
Python library for easily interacting with trained machine learning models
|
28 |
+
""", elem_classes=["md-custom"], header_links=True)
|
29 |
+
app.render()
|
30 |
+
gr.Markdown(
|
31 |
+
"""
|
32 |
+
## Installation
|
33 |
+
|
34 |
+
```bash
|
35 |
+
pip install gradio_unifiedaudio
|
36 |
+
```
|
37 |
+
|
38 |
+
## Usage
|
39 |
+
|
40 |
+
```python
|
41 |
+
|
42 |
+
import gradio as gr
|
43 |
+
from gradio_unifiedaudio import UnifiedAudio
|
44 |
+
from os.path import abspath, join, pardir
|
45 |
+
from pathlib import Path
|
46 |
+
|
47 |
+
example = UnifiedAudio().example_inputs()
|
48 |
+
dir_ = Path(__file__).parent
|
49 |
+
|
50 |
+
def test_mic(audio):
|
51 |
+
return UnifiedAudio(value=audio)
|
52 |
+
|
53 |
+
with gr.Blocks() as demo:
|
54 |
+
mic = UnifiedAudio(sources="microphone")
|
55 |
+
mic.change(test_mic, mic, mic)
|
56 |
+
|
57 |
+
if __name__ == '__main__':
|
58 |
+
demo.launch()
|
59 |
+
|
60 |
+
```
|
61 |
+
""", elem_classes=["md-custom"], header_links=True)
|
62 |
+
|
63 |
+
|
64 |
+
gr.Markdown("""
|
65 |
+
## `UnifiedAudio`
|
66 |
+
|
67 |
+
### Initialization
|
68 |
+
""", elem_classes=["md-custom"], header_links=True)
|
69 |
+
|
70 |
+
gr.ParamViewer(value=_docs["UnifiedAudio"]["members"]["__init__"], linkify=['WaveformOptions'])
|
71 |
+
|
72 |
+
|
73 |
+
gr.Markdown("### Events")
|
74 |
+
gr.ParamViewer(value=_docs["UnifiedAudio"]["events"], linkify=['Event'])
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
gr.Markdown("""
|
80 |
+
|
81 |
+
### User function
|
82 |
+
|
83 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
84 |
+
|
85 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
86 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
87 |
+
|
88 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
89 |
+
|
90 |
+
- **As output:** Should return, audio data in either of the following formats: a tuple of (sample_rate, data), or a string filepath or URL to an audio file, or None.
|
91 |
+
|
92 |
+
```python
|
93 |
+
def predict(
|
94 |
+
value: tuple[int, numpy.ndarray] | str | None
|
95 |
+
) -> tuple[int, numpy.ndarray]
|
96 |
+
| str
|
97 |
+
| pathlib.Path
|
98 |
+
| bytes
|
99 |
+
| None:
|
100 |
+
return value
|
101 |
+
```
|
102 |
+
""", elem_classes=["md-custom", "UnifiedAudio-user-fn"], header_links=True)
|
103 |
+
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
code_WaveformOptions = gr.Markdown("""
|
108 |
+
## `WaveformOptions`
|
109 |
+
```python
|
110 |
+
class WaveformOptions(TypedDict, total=False):
|
111 |
+
waveform_color: str
|
112 |
+
waveform_progress_color: str
|
113 |
+
show_controls: bool
|
114 |
+
skip_length: int
|
115 |
+
```""", elem_classes=["md-custom", "WaveformOptions"], header_links=True)
|
116 |
+
|
117 |
+
demo.load(None, js=r"""function() {
|
118 |
+
const refs = {
|
119 |
+
WaveformOptions: [], };
|
120 |
+
const user_fn_refs = {
|
121 |
+
UnifiedAudio: [], };
|
122 |
+
requestAnimationFrame(() => {
|
123 |
+
|
124 |
+
Object.entries(user_fn_refs).forEach(([key, refs]) => {
|
125 |
+
if (refs.length > 0) {
|
126 |
+
const el = document.querySelector(`.${key}-user-fn`);
|
127 |
+
if (!el) return;
|
128 |
+
refs.forEach(ref => {
|
129 |
+
el.innerHTML = el.innerHTML.replace(
|
130 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
131 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
132 |
+
);
|
133 |
+
})
|
134 |
+
}
|
135 |
+
})
|
136 |
+
|
137 |
+
Object.entries(refs).forEach(([key, refs]) => {
|
138 |
+
if (refs.length > 0) {
|
139 |
+
const el = document.querySelector(`.${key}`);
|
140 |
+
if (!el) return;
|
141 |
+
refs.forEach(ref => {
|
142 |
+
el.innerHTML = el.innerHTML.replace(
|
143 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
144 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
145 |
+
);
|
146 |
+
})
|
147 |
+
}
|
148 |
+
})
|
149 |
+
})
|
150 |
+
}
|
151 |
+
|
152 |
+
""")
|
153 |
+
|
154 |
+
demo.launch()
|
src/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
src/.gitignore
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.eggs/
|
2 |
+
dist/
|
3 |
+
*.pyc
|
4 |
+
__pycache__/
|
5 |
+
*.py[cod]
|
6 |
+
*$py.class
|
7 |
+
__tmp/*
|
8 |
+
*.pyi
|
9 |
+
node_modules
|
src/README.md
ADDED
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# `gradio_unifiedaudio`
|
3 |
+
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.2%20-%20orange">
|
4 |
+
|
5 |
+
Python library for easily interacting with trained machine learning models
|
6 |
+
|
7 |
+
## Installation
|
8 |
+
|
9 |
+
```bash
|
10 |
+
pip install gradio_unifiedaudio
|
11 |
+
```
|
12 |
+
|
13 |
+
## Usage
|
14 |
+
|
15 |
+
```python
|
16 |
+
|
17 |
+
import gradio as gr
|
18 |
+
from gradio_unifiedaudio import UnifiedAudio
|
19 |
+
from os.path import abspath, join, pardir
|
20 |
+
from pathlib import Path
|
21 |
+
|
22 |
+
example = UnifiedAudio().example_inputs()
|
23 |
+
dir_ = Path(__file__).parent
|
24 |
+
|
25 |
+
def test_mic(audio):
|
26 |
+
return UnifiedAudio(value=audio)
|
27 |
+
|
28 |
+
with gr.Blocks() as demo:
|
29 |
+
mic = UnifiedAudio(sources="microphone")
|
30 |
+
mic.change(test_mic, mic, mic)
|
31 |
+
|
32 |
+
if __name__ == '__main__':
|
33 |
+
demo.launch()
|
34 |
+
|
35 |
+
```
|
36 |
+
|
37 |
+
## `UnifiedAudio`
|
38 |
+
|
39 |
+
### Initialization
|
40 |
+
|
41 |
+
<table>
|
42 |
+
<thead>
|
43 |
+
<tr>
|
44 |
+
<th align="left">name</th>
|
45 |
+
<th align="left" style="width: 25%;">type</th>
|
46 |
+
<th align="left">default</th>
|
47 |
+
<th align="left">description</th>
|
48 |
+
</tr>
|
49 |
+
</thead>
|
50 |
+
<tbody>
|
51 |
+
<tr>
|
52 |
+
<td align="left"><code>value</code></td>
|
53 |
+
<td align="left" style="width: 25%;">
|
54 |
+
|
55 |
+
```python
|
56 |
+
str
|
57 |
+
| pathlib.Path
|
58 |
+
| tuple[int, numpy.ndarray]
|
59 |
+
| Callable
|
60 |
+
| None
|
61 |
+
```
|
62 |
+
|
63 |
+
</td>
|
64 |
+
<td align="left"><code>None</code></td>
|
65 |
+
<td align="left">A path, URL, or [sample_rate, numpy array] tuple (sample rate in Hz, audio data as a float or int numpy array) for the default value that UnifiedAudio component is going to take. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>
|
66 |
+
</tr>
|
67 |
+
|
68 |
+
<tr>
|
69 |
+
<td align="left"><code>image</code></td>
|
70 |
+
<td align="left" style="width: 25%;">
|
71 |
+
|
72 |
+
```python
|
73 |
+
str | None
|
74 |
+
```
|
75 |
+
|
76 |
+
</td>
|
77 |
+
<td align="left"><code>None</code></td>
|
78 |
+
<td align="left">A path or URL to an image to display above the audio component. If None, no image will be displayed.</td>
|
79 |
+
</tr>
|
80 |
+
|
81 |
+
<tr>
|
82 |
+
<td align="left"><code>sources</code></td>
|
83 |
+
<td align="left" style="width: 25%;">
|
84 |
+
|
85 |
+
```python
|
86 |
+
list["upload" | "microphone"] | None
|
87 |
+
```
|
88 |
+
|
89 |
+
</td>
|
90 |
+
<td align="left"><code>None</code></td>
|
91 |
+
<td align="left">A list of sources permitted for audio. "upload" creates a box where user can drop an audio file, "microphone" creates a microphone input. The first element in the list will be used as the default source. If None, defaults to ["upload", "microphone"], or ["microphone"] if `streaming` is True.</td>
|
92 |
+
</tr>
|
93 |
+
|
94 |
+
<tr>
|
95 |
+
<td align="left"><code>type</code></td>
|
96 |
+
<td align="left" style="width: 25%;">
|
97 |
+
|
98 |
+
```python
|
99 |
+
"numpy" | "filepath"
|
100 |
+
```
|
101 |
+
|
102 |
+
</td>
|
103 |
+
<td align="left"><code>"numpy"</code></td>
|
104 |
+
<td align="left">The format the audio file is converted to before being passed into the prediction function. "numpy" converts the audio to a tuple consisting of: (int sample rate, numpy.array for the data), "filepath" passes a str path to a temporary file containing the audio.</td>
|
105 |
+
</tr>
|
106 |
+
|
107 |
+
<tr>
|
108 |
+
<td align="left"><code>label</code></td>
|
109 |
+
<td align="left" style="width: 25%;">
|
110 |
+
|
111 |
+
```python
|
112 |
+
str | None
|
113 |
+
```
|
114 |
+
|
115 |
+
</td>
|
116 |
+
<td align="left"><code>None</code></td>
|
117 |
+
<td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
|
118 |
+
</tr>
|
119 |
+
|
120 |
+
<tr>
|
121 |
+
<td align="left"><code>every</code></td>
|
122 |
+
<td align="left" style="width: 25%;">
|
123 |
+
|
124 |
+
```python
|
125 |
+
float | None
|
126 |
+
```
|
127 |
+
|
128 |
+
</td>
|
129 |
+
<td align="left"><code>None</code></td>
|
130 |
+
<td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
|
131 |
+
</tr>
|
132 |
+
|
133 |
+
<tr>
|
134 |
+
<td align="left"><code>show_label</code></td>
|
135 |
+
<td align="left" style="width: 25%;">
|
136 |
+
|
137 |
+
```python
|
138 |
+
bool | None
|
139 |
+
```
|
140 |
+
|
141 |
+
</td>
|
142 |
+
<td align="left"><code>None</code></td>
|
143 |
+
<td align="left">if True, will display label.</td>
|
144 |
+
</tr>
|
145 |
+
|
146 |
+
<tr>
|
147 |
+
<td align="left"><code>container</code></td>
|
148 |
+
<td align="left" style="width: 25%;">
|
149 |
+
|
150 |
+
```python
|
151 |
+
bool
|
152 |
+
```
|
153 |
+
|
154 |
+
</td>
|
155 |
+
<td align="left"><code>True</code></td>
|
156 |
+
<td align="left">If True, will place the component in a container - providing some extra padding around the border.</td>
|
157 |
+
</tr>
|
158 |
+
|
159 |
+
<tr>
|
160 |
+
<td align="left"><code>scale</code></td>
|
161 |
+
<td align="left" style="width: 25%;">
|
162 |
+
|
163 |
+
```python
|
164 |
+
int | None
|
165 |
+
```
|
166 |
+
|
167 |
+
</td>
|
168 |
+
<td align="left"><code>None</code></td>
|
169 |
+
<td align="left">relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.</td>
|
170 |
+
</tr>
|
171 |
+
|
172 |
+
<tr>
|
173 |
+
<td align="left"><code>min_width</code></td>
|
174 |
+
<td align="left" style="width: 25%;">
|
175 |
+
|
176 |
+
```python
|
177 |
+
int
|
178 |
+
```
|
179 |
+
|
180 |
+
</td>
|
181 |
+
<td align="left"><code>160</code></td>
|
182 |
+
<td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
|
183 |
+
</tr>
|
184 |
+
|
185 |
+
<tr>
|
186 |
+
<td align="left"><code>interactive</code></td>
|
187 |
+
<td align="left" style="width: 25%;">
|
188 |
+
|
189 |
+
```python
|
190 |
+
bool | None
|
191 |
+
```
|
192 |
+
|
193 |
+
</td>
|
194 |
+
<td align="left"><code>None</code></td>
|
195 |
+
<td align="left">if True, will allow users to upload and edit a audio file; if False, can only be used to play audio. If not provided, this is inferred based on whether the component is used as an input or output.</td>
|
196 |
+
</tr>
|
197 |
+
|
198 |
+
<tr>
|
199 |
+
<td align="left"><code>visible</code></td>
|
200 |
+
<td align="left" style="width: 25%;">
|
201 |
+
|
202 |
+
```python
|
203 |
+
bool
|
204 |
+
```
|
205 |
+
|
206 |
+
</td>
|
207 |
+
<td align="left"><code>True</code></td>
|
208 |
+
<td align="left">If False, component will be hidden.</td>
|
209 |
+
</tr>
|
210 |
+
|
211 |
+
<tr>
|
212 |
+
<td align="left"><code>streaming</code></td>
|
213 |
+
<td align="left" style="width: 25%;">
|
214 |
+
|
215 |
+
```python
|
216 |
+
bool
|
217 |
+
```
|
218 |
+
|
219 |
+
</td>
|
220 |
+
<td align="left"><code>False</code></td>
|
221 |
+
<td align="left">If set to True when used in a `live` interface as an input, will automatically stream webcam feed. When used set as an output, takes audio chunks yield from the backend and combines them into one streaming audio output.</td>
|
222 |
+
</tr>
|
223 |
+
|
224 |
+
<tr>
|
225 |
+
<td align="left"><code>elem_id</code></td>
|
226 |
+
<td align="left" style="width: 25%;">
|
227 |
+
|
228 |
+
```python
|
229 |
+
str | None
|
230 |
+
```
|
231 |
+
|
232 |
+
</td>
|
233 |
+
<td align="left"><code>None</code></td>
|
234 |
+
<td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
235 |
+
</tr>
|
236 |
+
|
237 |
+
<tr>
|
238 |
+
<td align="left"><code>elem_classes</code></td>
|
239 |
+
<td align="left" style="width: 25%;">
|
240 |
+
|
241 |
+
```python
|
242 |
+
list[str] | str | None
|
243 |
+
```
|
244 |
+
|
245 |
+
</td>
|
246 |
+
<td align="left"><code>None</code></td>
|
247 |
+
<td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
248 |
+
</tr>
|
249 |
+
|
250 |
+
<tr>
|
251 |
+
<td align="left"><code>render</code></td>
|
252 |
+
<td align="left" style="width: 25%;">
|
253 |
+
|
254 |
+
```python
|
255 |
+
bool
|
256 |
+
```
|
257 |
+
|
258 |
+
</td>
|
259 |
+
<td align="left"><code>True</code></td>
|
260 |
+
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
|
261 |
+
</tr>
|
262 |
+
|
263 |
+
<tr>
|
264 |
+
<td align="left"><code>format</code></td>
|
265 |
+
<td align="left" style="width: 25%;">
|
266 |
+
|
267 |
+
```python
|
268 |
+
"wav" | "mp3"
|
269 |
+
```
|
270 |
+
|
271 |
+
</td>
|
272 |
+
<td align="left"><code>"wav"</code></td>
|
273 |
+
<td align="left">The file format to save audio files. Either 'wav' or 'mp3'. wav files are lossless but will tend to be larger files. mp3 files tend to be smaller. Default is wav. Applies both when this component is used as an input (when `type` is "format") and when this component is used as an output.</td>
|
274 |
+
</tr>
|
275 |
+
|
276 |
+
<tr>
|
277 |
+
<td align="left"><code>autoplay</code></td>
|
278 |
+
<td align="left" style="width: 25%;">
|
279 |
+
|
280 |
+
```python
|
281 |
+
bool
|
282 |
+
```
|
283 |
+
|
284 |
+
</td>
|
285 |
+
<td align="left"><code>False</code></td>
|
286 |
+
<td align="left">Whether to automatically play the audio when the component is used as an output. Note: browsers will not autoplay audio files if the user has not interacted with the page yet.</td>
|
287 |
+
</tr>
|
288 |
+
|
289 |
+
<tr>
|
290 |
+
<td align="left"><code>show_share_button</code></td>
|
291 |
+
<td align="left" style="width: 25%;">
|
292 |
+
|
293 |
+
```python
|
294 |
+
bool | None
|
295 |
+
```
|
296 |
+
|
297 |
+
</td>
|
298 |
+
<td align="left"><code>None</code></td>
|
299 |
+
<td align="left">If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.</td>
|
300 |
+
</tr>
|
301 |
+
|
302 |
+
<tr>
|
303 |
+
<td align="left"><code>min_length</code></td>
|
304 |
+
<td align="left" style="width: 25%;">
|
305 |
+
|
306 |
+
```python
|
307 |
+
int | None
|
308 |
+
```
|
309 |
+
|
310 |
+
</td>
|
311 |
+
<td align="left"><code>None</code></td>
|
312 |
+
<td align="left">The minimum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no minimum length.</td>
|
313 |
+
</tr>
|
314 |
+
|
315 |
+
<tr>
|
316 |
+
<td align="left"><code>max_length</code></td>
|
317 |
+
<td align="left" style="width: 25%;">
|
318 |
+
|
319 |
+
```python
|
320 |
+
int | None
|
321 |
+
```
|
322 |
+
|
323 |
+
</td>
|
324 |
+
<td align="left"><code>None</code></td>
|
325 |
+
<td align="left">The maximum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no maximum length.</td>
|
326 |
+
</tr>
|
327 |
+
|
328 |
+
<tr>
|
329 |
+
<td align="left"><code>waveform_options</code></td>
|
330 |
+
<td align="left" style="width: 25%;">
|
331 |
+
|
332 |
+
```python
|
333 |
+
WaveformOptions | None
|
334 |
+
```
|
335 |
+
|
336 |
+
</td>
|
337 |
+
<td align="left"><code>None</code></td>
|
338 |
+
<td align="left">A dictionary of options for the waveform display. Options include: waveform_color (str), waveform_progress_color (str), show_controls (bool), skip_length (int). Default is None, which uses the default values for these options.</td>
|
339 |
+
</tr>
|
340 |
+
</tbody></table>
|
341 |
+
|
342 |
+
|
343 |
+
### Events
|
344 |
+
|
345 |
+
| name | description |
|
346 |
+
|:-----|:------------|
|
347 |
+
| `stream` | This listener is triggered when the user streams the UnifiedAudio. |
|
348 |
+
| `change` | Triggered when the value of the UnifiedAudio changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
|
349 |
+
| `clear` | This listener is triggered when the user clears the UnifiedAudio using the X button for the component. |
|
350 |
+
| `play` | This listener is triggered when the user plays the media in the UnifiedAudio. |
|
351 |
+
| `pause` | This listener is triggered when the media in the UnifiedAudio stops for any reason. |
|
352 |
+
| `stop` | This listener is triggered when the user reaches the end of the media playing in the UnifiedAudio. |
|
353 |
+
| `start_recording` | This listener is triggered when the user starts recording with the UnifiedAudio. |
|
354 |
+
| `pause_recording` | This listener is triggered when the user pauses recording with the UnifiedAudio. |
|
355 |
+
| `stop_recording` | This listener is triggered when the user stops recording with the UnifiedAudio. |
|
356 |
+
| `upload` | This listener is triggered when the user uploads a file into the UnifiedAudio. |
|
357 |
+
|
358 |
+
|
359 |
+
|
360 |
+
### User function
|
361 |
+
|
362 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
363 |
+
|
364 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
365 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
366 |
+
|
367 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
368 |
+
|
369 |
+
- **As input:** Should return, audio data in either of the following formats: a tuple of (sample_rate, data), or a string filepath or URL to an audio file, or None.
|
370 |
+
|
371 |
+
```python
|
372 |
+
def predict(
|
373 |
+
value: tuple[int, numpy.ndarray] | str | None
|
374 |
+
) -> tuple[int, numpy.ndarray]
|
375 |
+
| str
|
376 |
+
| pathlib.Path
|
377 |
+
| bytes
|
378 |
+
| None:
|
379 |
+
return value
|
380 |
+
```
|
381 |
+
|
382 |
+
|
383 |
+
## `WaveformOptions`
|
384 |
+
```python
|
385 |
+
class WaveformOptions(TypedDict, total=False):
|
386 |
+
waveform_color: str
|
387 |
+
waveform_progress_color: str
|
388 |
+
show_controls: bool
|
389 |
+
skip_length: int
|
390 |
+
```
|
src/backend/gradio_unifiedaudio/__init__.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from .unifiedaudio import UnifiedAudio
|
3 |
+
|
4 |
+
__all__ = ['UnifiedAudio']
|
src/backend/gradio_unifiedaudio/templates/component/__vite-browser-external-2447137e.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const e = {};
|
2 |
+
export {
|
3 |
+
e as default
|
4 |
+
};
|
src/backend/gradio_unifiedaudio/templates/component/index-c48f56d2.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
src/backend/gradio_unifiedaudio/templates/component/index.js
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { E as s, a as t, A as i, S as o, I as r } from "./index-c48f56d2.js";
|
2 |
+
export {
|
3 |
+
s as BaseExample,
|
4 |
+
t as BaseInteractiveAudio,
|
5 |
+
i as BasePlayer,
|
6 |
+
o as BaseStaticAudio,
|
7 |
+
r as default
|
8 |
+
};
|
src/backend/gradio_unifiedaudio/templates/component/module-2c3384e6.js
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const w = (t) => (n) => {
|
2 |
+
const e = t(n);
|
3 |
+
return n.add(e), e;
|
4 |
+
}, N = (t) => (n, e) => (t.set(n, e), e), f = Number.MAX_SAFE_INTEGER === void 0 ? 9007199254740991 : Number.MAX_SAFE_INTEGER, g = 536870912, _ = g * 2, O = (t, n) => (e) => {
|
5 |
+
const r = n.get(e);
|
6 |
+
let s = r === void 0 ? e.size : r < _ ? r + 1 : 0;
|
7 |
+
if (!e.has(s))
|
8 |
+
return t(e, s);
|
9 |
+
if (e.size < g) {
|
10 |
+
for (; e.has(s); )
|
11 |
+
s = Math.floor(Math.random() * _);
|
12 |
+
return t(e, s);
|
13 |
+
}
|
14 |
+
if (e.size > f)
|
15 |
+
throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");
|
16 |
+
for (; e.has(s); )
|
17 |
+
s = Math.floor(Math.random() * f);
|
18 |
+
return t(e, s);
|
19 |
+
}, M = /* @__PURE__ */ new WeakMap(), m = N(M), h = O(m, M), I = w(h), R = (t) => typeof t.start == "function", p = /* @__PURE__ */ new WeakMap(), A = (t) => ({
|
20 |
+
...t,
|
21 |
+
connect: ({ call: n }) => async () => {
|
22 |
+
const { port1: e, port2: r } = new MessageChannel(), s = await n("connect", { port: e }, [e]);
|
23 |
+
return p.set(r, s), r;
|
24 |
+
},
|
25 |
+
disconnect: ({ call: n }) => async (e) => {
|
26 |
+
const r = p.get(e);
|
27 |
+
if (r === void 0)
|
28 |
+
throw new Error("The given port is not connected.");
|
29 |
+
await n("disconnect", { portId: r });
|
30 |
+
},
|
31 |
+
isSupported: ({ call: n }) => () => n("isSupported")
|
32 |
+
}), E = /* @__PURE__ */ new WeakMap(), b = (t) => {
|
33 |
+
if (E.has(t))
|
34 |
+
return E.get(t);
|
35 |
+
const n = /* @__PURE__ */ new Map();
|
36 |
+
return E.set(t, n), n;
|
37 |
+
}, W = (t) => {
|
38 |
+
const n = A(t);
|
39 |
+
return (e) => {
|
40 |
+
const r = b(e);
|
41 |
+
e.addEventListener("message", ({ data: o }) => {
|
42 |
+
const { id: a } = o;
|
43 |
+
if (a !== null && r.has(a)) {
|
44 |
+
const { reject: u, resolve: c } = r.get(a);
|
45 |
+
r.delete(a), o.error === void 0 ? c(o.result) : u(new Error(o.error.message));
|
46 |
+
}
|
47 |
+
}), R(e) && e.start();
|
48 |
+
const s = (o, a = null, u = []) => new Promise((c, l) => {
|
49 |
+
const d = h(r);
|
50 |
+
r.set(d, { reject: l, resolve: c }), a === null ? e.postMessage({ id: d, method: o }, u) : e.postMessage({ id: d, method: o, params: a }, u);
|
51 |
+
}), T = (o, a, u = []) => {
|
52 |
+
e.postMessage({ id: null, method: o, params: a }, u);
|
53 |
+
};
|
54 |
+
let i = {};
|
55 |
+
for (const [o, a] of Object.entries(n))
|
56 |
+
i = { ...i, [o]: a({ call: s, notify: T }) };
|
57 |
+
return { ...i };
|
58 |
+
};
|
59 |
+
};
|
60 |
+
export {
|
61 |
+
I as a,
|
62 |
+
W as c,
|
63 |
+
h as g
|
64 |
+
};
|
src/backend/gradio_unifiedaudio/templates/component/module-ae1e1517.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
src/backend/gradio_unifiedaudio/templates/component/module-ef7e7a9a.js
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { c as i } from "./module-2c3384e6.js";
|
2 |
+
const c = i({
|
3 |
+
characterize: ({ call: e }) => () => e("characterize"),
|
4 |
+
encode: ({ call: e }) => (r, n) => e("encode", { recordingId: r, timeslice: n }),
|
5 |
+
record: ({ call: e }) => async (r, n, o) => {
|
6 |
+
await e("record", { recordingId: r, sampleRate: n, typedArrays: o }, o.map(({ buffer: a }) => a));
|
7 |
+
}
|
8 |
+
}), u = (e) => {
|
9 |
+
const r = new Worker(e);
|
10 |
+
return c(r);
|
11 |
+
}, l = `(()=>{var e={775:function(e,t,r){!function(e,t,r,n){"use strict";var o=function(e,t){return void 0===t?e:t.reduce((function(e,t){if("capitalize"===t){var o=e.charAt(0).toUpperCase(),s=e.slice(1);return"".concat(o).concat(s)}return"dashify"===t?r(e):"prependIndefiniteArticle"===t?"".concat(n(e)," ").concat(e):e}),e)},s=function(e){var t=e.name+e.modifiers.map((function(e){return"\\\\.".concat(e,"\\\\(\\\\)")})).join("");return new RegExp("\\\\$\\\\{".concat(t,"}"),"g")},a=function(e,r){for(var n=/\\\${([^.}]+)((\\.[^(]+\\(\\))*)}/g,a=[],i=n.exec(e);null!==i;){var u={modifiers:[],name:i[1]};if(void 0!==i[3])for(var c=/\\.[^(]+\\(\\)/g,l=c.exec(i[2]);null!==l;)u.modifiers.push(l[0].slice(1,-2)),l=c.exec(i[2]);a.push(u),i=n.exec(e)}var d=a.reduce((function(e,n){return e.map((function(e){return"string"==typeof e?e.split(s(n)).reduce((function(e,s,a){return 0===a?[s]:n.name in r?[].concat(t(e),[o(r[n.name],n.modifiers),s]):[].concat(t(e),[function(e){return o(e[n.name],n.modifiers)},s])}),[]):[e]})).reduce((function(e,r){return[].concat(t(e),t(r))}),[])}),[e]);return function(e){return d.reduce((function(r,n){return[].concat(t(r),"string"==typeof n?[n]:[n(e)])}),[]).join("")}},i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0===e.code?void 0:a(e.code,t),n=void 0===e.message?void 0:a(e.message,t);function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0,s=void 0===o&&(t instanceof Error||void 0!==t.code&&"Exception"===t.code.slice(-9))?{cause:t,missingParameters:{}}:{cause:o,missingParameters:t},a=s.cause,i=s.missingParameters,u=void 0===n?new Error:new Error(n(i));return null!==a&&(u.cause=a),void 0!==r&&(u.code=r(i)),void 0!==e.status&&(u.status=e.status),u}return o};e.compile=i}(t,r(106),r(881),r(507))},881:e=>{"use strict";e.exports=(e,t)=>{if("string"!=typeof e)throw new TypeError("expected a string");return e.trim().replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\\W/g,(e=>/[À-ž]/.test(e)?e:"-")).replace(/^-+|-+$/g,"").replace(/-{2,}/g,(e=>t&&t.condense?"-":e)).toLowerCase()}},107:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)},507:e=>{var t=function(e){var t,r,n=/\\w+/.exec(e);if(!n)return"an";var o=(r=n[0]).toLowerCase(),s=["honest","hour","hono"];for(t in s)if(0==o.indexOf(s[t]))return"an";if(1==o.length)return"aedhilmnorsx".indexOf(o)>=0?"an":"a";if(r.match(/(?!FJO|[HLMNS]Y.|RY[EO]|SQU|(F[LR]?|[HL]|MN?|N|RH?|S[CHKLMNPTVW]?|X(YL)?)[AEIOU])[FHLMNRSX][A-Z]/))return"an";var a=[/^e[uw]/,/^onc?e\\b/,/^uni([^nmd]|mo)/,/^u[bcfhjkqrst][aeiou]/];for(t=0;t<a.length;t++)if(o.match(a[t]))return"a";return r.match(/^U[NK][AIEO]/)?"a":r==r.toUpperCase()?"aedhilmnorsx".indexOf(o[0])>=0?"an":"a":"aeiou".indexOf(o[0])>=0||o.match(/^y(b[lor]|cl[ea]|fere|gg|p[ios]|rou|tt)/)?"an":"a"};void 0!==e.exports?e.exports=t:window.indefiniteArticle=t},768:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.__esModule=!0,e.exports.default=e.exports},907:(e,t,r)=>{var n=r(768);e.exports=function(e){if(Array.isArray(e))return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},642:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},344:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},106:(e,t,r)=>{var n=r(907),o=r(642),s=r(906),a=r(344);e.exports=function(e){return n(e)||o(e)||s(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},906:(e,t,r)=>{var n=r(768);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";var e=r(775);const t=-32603,n=-32602,o=-32601,s=(0,e.compile)({message:'The requested method called "\${method}" is not supported.',status:o}),a=(0,e.compile)({message:'The handler of the method called "\${method}" returned no required result.',status:t}),i=(0,e.compile)({message:'The handler of the method called "\${method}" returned an unexpected result.',status:t}),u=(0,e.compile)({message:'The specified parameter called "portId" with the given value "\${portId}" does not identify a port connected to this worker.',status:n});var c=r(107);const l=new Map,d=(e,t,r)=>({...t,connect:r=>{let{port:n}=r;n.start();const o=e(n,t),s=(0,c.generateUniqueNumber)(l);return l.set(s,(()=>{o(),n.close(),l.delete(s)})),{result:s}},disconnect:e=>{let{portId:t}=e;const r=l.get(t);if(void 0===r)throw u({portId:t.toString()});return r(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=t=>{let{data:r}=t;return e(null!==r)},n.postMessage(t,[t])}))){const e=r();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),f=function(e,t){const r=d(f,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0),n=((e,t)=>async r=>{let{data:{id:n,method:o,params:u}}=r;const c=t[o];try{if(void 0===c)throw s({method:o});const t=void 0===u?c():c(u);if(void 0===t)throw a({method:o});const r=t instanceof Promise?await t:t;if(null===n){if(void 0!==r.result)throw i({method:o})}else{if(void 0===r.result)throw i({method:o});const{result:t,transferables:s=[]}=r;e.postMessage({id:n,result:t},s)}}catch(t){const{message:r,status:o=-32603}=t;e.postMessage({error:{code:o,message:r},id:n})}})(e,r);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},p=e=>e.reduce(((e,t)=>e+t.length),0),m=(e,t)=>{const r=[];let n=0;e:for(;n<t;){const t=e.length;for(let o=0;o<t;o+=1){const t=e[o];void 0===r[o]&&(r[o]=[]);const s=t.shift();if(void 0===s)break e;r[o].push(s),0===o&&(n+=s.length)}}if(n>t){const o=n-t;r.forEach(((t,r)=>{const n=t.pop(),s=n.length-o;t.push(n.subarray(0,s)),e[r].unshift(n.subarray(s))}))}return r},h=new Map,v=(e=>(t,r,n)=>{const o=e.get(t);if(void 0===o){const o={channelDataArrays:n.map((e=>[e])),isComplete:!0,sampleRate:r};return e.set(t,o),o}return o.channelDataArrays.forEach(((e,t)=>e.push(n[t]))),o})(h),g=((e,t)=>(r,n,o,s)=>{const a=o>>3,i="subsequent"===n?0:44,u=r.length,c=e(r[0]),l=new ArrayBuffer(c*u*a+i),d=new DataView(l);return"subsequent"!==n&&t(d,o,u,"complete"===n?c:Number.POSITIVE_INFINITY,s),r.forEach(((e,t)=>{let r=i+t*a;e.forEach((e=>{const t=e.length;for(let n=0;n<t;n+=1){const t=e[n];d.setInt16(r,t<0?32768*Math.max(-1,t):32767*Math.min(1,t),!0),r+=u*a}}))})),[l]})(p,((e,t,r,n,o)=>{const s=t>>3,a=Math.min(n*r*s,4294967251);e.setUint32(0,1380533830),e.setUint32(4,a+36,!0),e.setUint32(8,1463899717),e.setUint32(12,1718449184),e.setUint32(16,16,!0),e.setUint16(20,1,!0),e.setUint16(22,r,!0),e.setUint32(24,o,!0),e.setUint32(28,o*r*s,!0),e.setUint16(32,r*s,!0),e.setUint16(34,t,!0),e.setUint32(36,1684108385),e.setUint32(40,a,!0)})),x=new Map;f(self,{characterize:()=>({result:/^audio\\/wav$/}),encode:e=>{let{recordingId:t,timeslice:r}=e;const n=x.get(t);void 0!==n&&(x.delete(t),n.reject(new Error("Another request was made to initiate an encoding.")));const o=h.get(t);if(null!==r){if(void 0===o||p(o.channelDataArrays[0])*(1e3/o.sampleRate)<r)return new Promise(((e,n)=>{x.set(t,{reject:n,resolve:e,timeslice:r})}));const e=m(o.channelDataArrays,Math.ceil(r*(o.sampleRate/1e3))),n=g(e,o.isComplete?"initial":"subsequent",16,o.sampleRate);return o.isComplete=!1,{result:n,transferables:n}}if(void 0!==o){const e=g(o.channelDataArrays,o.isComplete?"complete":"subsequent",16,o.sampleRate);return h.delete(t),{result:e,transferables:e}}return{result:[],transferables:[]}},record:e=>{let{recordingId:t,sampleRate:r,typedArrays:n}=e;const o=v(t,r,n),s=x.get(t);if(void 0!==s&&p(o.channelDataArrays[0])*(1e3/r)>=s.timeslice){const e=m(o.channelDataArrays,Math.ceil(s.timeslice*(r/1e3))),n=g(e,o.isComplete?"initial":"subsequent",16,r);o.isComplete=!1,x.delete(t),s.resolve({result:n,transferables:n})}return{result:null}}})})()})();`, d = new Blob([l], { type: "application/javascript; charset=utf-8" }), s = URL.createObjectURL(d), t = u(s), p = t.characterize, m = t.connect, h = t.disconnect, g = t.encode, v = t.isSupported, x = t.record;
|
12 |
+
URL.revokeObjectURL(s);
|
13 |
+
export {
|
14 |
+
p as characterize,
|
15 |
+
m as connect,
|
16 |
+
h as disconnect,
|
17 |
+
g as encode,
|
18 |
+
v as isSupported,
|
19 |
+
x as record
|
20 |
+
};
|
src/backend/gradio_unifiedaudio/templates/component/style.css
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.block.svelte-1t38q2d{position:relative;margin:0;box-shadow:var(--block-shadow);border-width:var(--block-border-width);border-color:var(--block-border-color);border-radius:var(--block-radius);background:var(--block-background-fill);width:100%;line-height:var(--line-sm)}.block.border_focus.svelte-1t38q2d{border-color:var(--color-accent)}.padded.svelte-1t38q2d{padding:var(--block-padding)}.hidden.svelte-1t38q2d{display:none}.hide-container.svelte-1t38q2d{margin:0;box-shadow:none;--block-border-width:0;background:transparent;padding:0;overflow:visible}div.svelte-1hnfib2{margin-bottom:var(--spacing-lg);color:var(--block-info-text-color);font-weight:var(--block-info-text-weight);font-size:var(--block-info-text-size);line-height:var(--line-sm)}span.has-info.svelte-22c38v{margin-bottom:var(--spacing-xs)}span.svelte-22c38v:not(.has-info){margin-bottom:var(--spacing-lg)}span.svelte-22c38v{display:inline-block;position:relative;z-index:var(--layer-4);border:solid var(--block-title-border-width) var(--block-title-border-color);border-radius:var(--block-title-radius);background:var(--block-title-background-fill);padding:var(--block-title-padding);color:var(--block-title-text-color);font-weight:var(--block-title-text-weight);font-size:var(--block-title-text-size);line-height:var(--line-sm)}.hide.svelte-22c38v{margin:0;height:0}label.svelte-9gxdi0{display:inline-flex;align-items:center;z-index:var(--layer-2);box-shadow:var(--block-label-shadow);border:var(--block-label-border-width) solid var(--border-color-primary);border-top:none;border-left:none;border-radius:var(--block-label-radius);background:var(--block-label-background-fill);padding:var(--block-label-padding);pointer-events:none;color:var(--block-label-text-color);font-weight:var(--block-label-text-weight);font-size:var(--block-label-text-size);line-height:var(--line-sm)}.gr-group label.svelte-9gxdi0{border-top-left-radius:0}label.float.svelte-9gxdi0{position:absolute;top:var(--block-label-margin);left:var(--block-label-margin)}label.svelte-9gxdi0:not(.float){position:static;margin-top:var(--block-label-margin);margin-left:var(--block-label-margin)}.hide.svelte-9gxdi0{height:0}span.svelte-9gxdi0{opacity:.8;margin-right:var(--size-2);width:calc(var(--block-label-text-size) - 1px);height:calc(var(--block-label-text-size) - 1px)}.hide-label.svelte-9gxdi0{box-shadow:none;border-width:0;background:transparent;overflow:visible}button.svelte-xtz2g8{display:flex;justify-content:center;align-items:center;gap:1px;z-index:var(--layer-2);border-radius:var(--radius-sm);color:var(--block-label-text-color);border:1px solid transparent}.padded.svelte-xtz2g8{padding:2px;background:var(--background-fill-primary);box-shadow:var(--shadow-drop);border:1px solid var(--button-secondary-border-color)}button.svelte-xtz2g8:hover{cursor:pointer;color:var(--color-accent)}.padded.svelte-xtz2g8:hover{border:2px solid var(--button-secondary-border-color-hover);padding:1px;color:var(--block-label-text-color)}span.svelte-xtz2g8{padding:0 1px;font-size:10px}div.svelte-xtz2g8{padding:2px;display:flex;align-items:flex-end}.small.svelte-xtz2g8{width:14px;height:14px}.large.svelte-xtz2g8{width:22px;height:22px}.pending.svelte-xtz2g8{animation:svelte-xtz2g8-flash .5s infinite}@keyframes svelte-xtz2g8-flash{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.empty.svelte-3w3rth{display:flex;justify-content:center;align-items:center;margin-top:calc(0px - var(--size-6));height:var(--size-full)}.icon.svelte-3w3rth{opacity:.5;height:var(--size-5);color:var(--body-text-color)}.small.svelte-3w3rth{min-height:calc(var(--size-32) - 20px)}.large.svelte-3w3rth{min-height:calc(var(--size-64) - 20px)}.unpadded_box.svelte-3w3rth{margin-top:0}.small_parent.svelte-3w3rth{min-height:100%!important}.dropdown-arrow.svelte-145leq6{fill:currentColor}.wrap.svelte-kzcjhc{display:flex;flex-direction:column;justify-content:center;align-items:center;min-height:var(--size-60);color:var(--block-label-text-color);line-height:var(--line-md);height:100%;padding-top:var(--size-3)}.or.svelte-kzcjhc{color:var(--body-text-color-subdued);display:flex}.icon-wrap.svelte-kzcjhc{width:30px;margin-bottom:var(--spacing-lg)}@media (--screen-md){.wrap.svelte-kzcjhc{font-size:var(--text-lg)}}.hovered.svelte-kzcjhc{color:var(--color-accent)}div.svelte-1nba87b{border-top:1px solid transparent;display:flex;max-height:100%;justify-content:center;gap:var(--spacing-sm);height:auto;align-items:flex-end;box-shadow:var(--shadow-drop);padding:var(--spacing-xl) 0;color:var(--block-label-text-color);flex-shrink:0;width:95%}.show_border.svelte-1nba87b{border-top:1px solid var(--block-border-color);margin-top:var(--spacing-xxl)}.source-selection.svelte-lde7lt{display:flex;align-items:center;justify-content:center;border-top:1px solid var(--border-color-primary);width:95%;bottom:0;left:0;right:0;margin-left:auto;margin-right:auto;align-self:flex-end}.icon.svelte-lde7lt{width:22px;height:22px;margin:var(--spacing-lg) var(--spacing-xs);padding:var(--spacing-xs);color:var(--neutral-400);border-radius:var(--radius-md)}.selected.svelte-lde7lt{color:var(--color-accent)}.icon.svelte-lde7lt:hover,.icon.svelte-lde7lt:focus{color:var(--color-accent)}.settings-wrapper.svelte-1duohn5.svelte-1duohn5{display:flex;justify-self:self-end}.text-button.svelte-1duohn5.svelte-1duohn5{border:1px solid var(--neutral-400);border-radius:var(--radius-sm);font-weight:300;font-size:var(--size-3);text-align:center;color:var(--neutral-400);height:var(--size-5);font-weight:700;padding:0 5px;margin-left:5px}.text-button.svelte-1duohn5.svelte-1duohn5:hover,.text-button.svelte-1duohn5.svelte-1duohn5:focus{color:var(--color-accent);border-color:var(--color-accent)}.controls.svelte-1duohn5.svelte-1duohn5{display:grid;grid-template-columns:1fr 1fr 1fr;margin-top:5px;overflow:hidden;align-items:center}@media (max-width: 320px){.controls.svelte-1duohn5.svelte-1duohn5{display:flex;flex-wrap:wrap}.controls.svelte-1duohn5 .svelte-1duohn5{margin:var(--spacing-sm)}.controls.svelte-1duohn5 .text-button.svelte-1duohn5{margin-left:0}}.action.svelte-1duohn5.svelte-1duohn5{width:var(--size-5);color:var(--neutral-400);margin-left:var(--spacing-md)}.icon.svelte-1duohn5.svelte-1duohn5:hover,.icon.svelte-1duohn5.svelte-1duohn5:focus{color:var(--color-accent)}.play-pause-wrapper.svelte-1duohn5.svelte-1duohn5{display:flex;justify-self:center}.playback.svelte-1duohn5.svelte-1duohn5{border:1px solid var(--neutral-400);border-radius:var(--radius-sm);width:5.5ch;font-weight:300;font-size:var(--size-3);text-align:center;color:var(--neutral-400);height:var(--size-5);font-weight:700}.playback.svelte-1duohn5.svelte-1duohn5:hover{color:var(--color-accent);border-color:var(--color-accent)}.rewind.svelte-1duohn5.svelte-1duohn5,.skip.svelte-1duohn5.svelte-1duohn5{margin:0 10px;color:var(--neutral-400)}.play-pause-button.svelte-1duohn5.svelte-1duohn5{width:var(--size-8);display:flex;align-items:center;justify-content:center;color:var(--neutral-400);fill:var(--neutral-400)}.component-wrapper.svelte-1iry1ax{padding:var(--size-3)}.timestamps.svelte-1iry1ax{display:flex;justify-content:space-between;align-items:center;width:100%;padding:var(--size-1) 0}#time.svelte-1iry1ax,#duration.svelte-1iry1ax{color:var(--neutral-400)}#trim-duration.svelte-1iry1ax{color:var(--color-accent);margin-right:var(--spacing-sm)}.waveform-container.svelte-1iry1ax{display:flex;align-items:center;justify-content:center;width:var(--size-full)}#waveform.svelte-1iry1ax{width:100%;height:100%;position:relative}audio.svelte-34w466.svelte-34w466{display:none}.image-container.svelte-34w466.svelte-34w466{position:relative;width:350px;height:350px;margin:auto}.image-player.svelte-34w466.svelte-34w466{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:50%;object-fit:cover}.play-icon.svelte-34w466.svelte-34w466,.pause-icon.svelte-34w466.svelte-34w466{position:absolute;top:50%;left:50%;width:75px;height:75px;transform:translate(-50%,-50%)}.pause-icon.svelte-34w466.svelte-34w466{opacity:0;transition:opacity .3s}.image-container.svelte-34w466:hover .pause-icon.svelte-34w466,.circle-container.svelte-34w466:hover .pause-icon.svelte-34w466{opacity:1}.circle-container.svelte-34w466:hover .waveform-bar.svelte-34w466{opacity:.5}.circle-container.svelte-34w466.svelte-34w466{width:350px;height:350px;margin:auto;border-radius:50%;border:3px solid white;position:relative;overflow:hidden;display:flex;align-items:center;justify-content:center}.waveform-bar.svelte-34w466.svelte-34w466{background-color:#fff;width:2%;height:20%;margin:0 1%;border-radius:5px;opacity:.5;transform-origin:bottom}.waveform-animation-0.svelte-34w466.svelte-34w466{animation:svelte-34w466-waveAnimation0 1s infinite ease-in-out;opacity:1}.waveform-animation-1.svelte-34w466.svelte-34w466{animation:svelte-34w466-waveAnimation1 1.5s infinite ease-in-out;opacity:1}.waveform-animation-2.svelte-34w466.svelte-34w466{animation:svelte-34w466-waveAnimation2 3s infinite ease-in-out;opacity:1}.waveform-animation-3.svelte-34w466.svelte-34w466{animation:svelte-34w466-waveAnimation3 2s infinite ease-in-out;opacity:1}.waveform-animation-4.svelte-34w466.svelte-34w466{animation:svelte-34w466-waveAnimation4 2.5s infinite ease-in-out;opacity:1}.waveform-animation-5.svelte-34w466.svelte-34w466{animation:svelte-34w466-waveAnimation5 3.5s infinite ease-in-out;opacity:1}@keyframes svelte-34w466-waveAnimation0{0%,to{height:50%}50%{height:15%}}@keyframes svelte-34w466-waveAnimation1{0%,to{height:45%}50%{height:25%}}@keyframes svelte-34w466-waveAnimation2{0%,to{height:40%}50%{height:60%}}@keyframes svelte-34w466-waveAnimation3{0%,to{height:70%}50%{height:25%}}@keyframes svelte-34w466-waveAnimation4{0%,to{height:25%}50%{height:70%}}@keyframes svelte-34w466-waveAnimation5{0%,to{height:60%}50%{height:15%}}button.svelte-a356bc{cursor:pointer;width:var(--size-full)}.hidden.svelte-a356bc{display:none;height:0;position:absolute}.center.svelte-a356bc{display:flex;justify-content:center}.flex.svelte-a356bc{display:flex;justify-content:center;align-items:center}input.svelte-a356bc{display:none}div.svelte-1wj0ocy{display:flex;top:var(--size-2);right:var(--size-2);justify-content:flex-end;gap:var(--spacing-sm);z-index:var(--layer-1)}.not-absolute.svelte-1wj0ocy{margin:var(--size-1)}.wrapper.svelte-g0zaxm{display:flex;justify-content:center;align-items:center;border-radius:50px}.microphone-icon.svelte-g0zaxm,.stop-icon.svelte-g0zaxm{display:flex;align-items:center;justify-content:center;height:100%}.record-button.svelte-g0zaxm{height:350px;width:350px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:white;border:6px solid rgb(0,140,255)}.stop-button.svelte-g0zaxm{height:350px;width:350px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:white;border:6px solid red}@keyframes svelte-g0zaxm-pulsate{0%{transform:scale(1)}50%{transform:scale(1.1)}to{transform:scale(1)}}.pulsate.svelte-g0zaxm{animation:svelte-g0zaxm-pulsate 1s infinite}.record-button.svelte-g0zaxm:disabled{cursor:not-allowed;opacity:.5}@keyframes svelte-g0zaxm-scaling{0%{background-color:var(--primary-600);scale:1}50%{background-color:var(--primary-600);scale:1.2}to{background-color:var(--primary-600);scale:1}}#microphone.svelte-1smaui2{width:100%;display:none}.component-wrapper.svelte-1smaui2{padding:var(--size-3)}.mic-wrap.svelte-1ho79kd{display:block;align-items:center;margin:var(--spacing-xl)}.stop-button-paused.svelte-1ho79kd{display:none;height:var(--size-8);width:var(--size-20);background-color:var(--block-background-fill);border-radius:var(--radius-3xl);align-items:center;border:1px solid var(--neutral-400);margin-right:5px}.stop-button-paused.svelte-1ho79kd:before{content:"";height:var(--size-4);width:var(--size-4);border-radius:var(--radius-full);background:var(--primary-600);margin:0 var(--spacing-xl)}.stop-button.svelte-1ho79kd:before{content:"";height:var(--size-4);width:var(--size-4);border-radius:var(--radius-full);background:var(--primary-600);margin:0 var(--spacing-xl);animation:scaling 1.8s infinite}.stop-button.svelte-1ho79kd{height:var(--size-8);width:var(--size-20);background-color:var(--block-background-fill);border-radius:var(--radius-3xl);align-items:center;border:1px solid var(--primary-600);margin-right:5px;display:flex}.record-button.svelte-1ho79kd:before{content:"";height:var(--size-4);width:var(--size-4);border-radius:var(--radius-full);background:var(--primary-600);margin:0 var(--spacing-xl)}.record-button.svelte-1ho79kd{height:var(--size-8);width:var(--size-24);background-color:var(--block-background-fill);border-radius:var(--radius-3xl);display:flex;align-items:center;border:1px solid var(--neutral-400)}svg.svelte-43sxxs.svelte-43sxxs{width:var(--size-20);height:var(--size-20)}svg.svelte-43sxxs path.svelte-43sxxs{fill:var(--loader-color)}div.svelte-43sxxs.svelte-43sxxs{z-index:var(--layer-2)}.margin.svelte-43sxxs.svelte-43sxxs{margin:var(--size-4)}.wrap.svelte-14miwb5.svelte-14miwb5{display:flex;flex-direction:column;justify-content:center;align-items:center;z-index:var(--layer-5);transition:opacity .1s ease-in-out;border-radius:var(--block-radius);background:var(--block-background-fill);padding:0 var(--size-6);max-height:var(--size-screen-h);overflow:hidden;pointer-events:none}.wrap.center.svelte-14miwb5.svelte-14miwb5{top:0;right:0;left:0}.wrap.default.svelte-14miwb5.svelte-14miwb5{top:0;right:0;bottom:0;left:0}.hide.svelte-14miwb5.svelte-14miwb5{opacity:0;pointer-events:none}.generating.svelte-14miwb5.svelte-14miwb5{animation:svelte-14miwb5-pulse 2s cubic-bezier(.4,0,.6,1) infinite;border:2px solid var(--color-accent);background:transparent}.translucent.svelte-14miwb5.svelte-14miwb5{background:none}@keyframes svelte-14miwb5-pulse{0%,to{opacity:1}50%{opacity:.5}}.loading.svelte-14miwb5.svelte-14miwb5{z-index:var(--layer-2);color:var(--body-text-color)}.eta-bar.svelte-14miwb5.svelte-14miwb5{position:absolute;top:0;right:0;bottom:0;left:0;transform-origin:left;opacity:.8;z-index:var(--layer-1);transition:10ms;background:var(--background-fill-secondary)}.progress-bar-wrap.svelte-14miwb5.svelte-14miwb5{border:1px solid var(--border-color-primary);background:var(--background-fill-primary);width:55.5%;height:var(--size-4)}.progress-bar.svelte-14miwb5.svelte-14miwb5{transform-origin:left;background-color:var(--loader-color);width:var(--size-full);height:var(--size-full)}.progress-level.svelte-14miwb5.svelte-14miwb5{display:flex;flex-direction:column;align-items:center;gap:1;z-index:var(--layer-2);width:var(--size-full)}.progress-level-inner.svelte-14miwb5.svelte-14miwb5{margin:var(--size-2) auto;color:var(--body-text-color);font-size:var(--text-sm);font-family:var(--font-mono)}.meta-text.svelte-14miwb5.svelte-14miwb5{position:absolute;top:0;right:0;z-index:var(--layer-2);padding:var(--size-1) var(--size-2);font-size:var(--text-sm);font-family:var(--font-mono)}.meta-text-center.svelte-14miwb5.svelte-14miwb5{display:flex;position:absolute;top:0;right:0;justify-content:center;align-items:center;transform:translateY(var(--size-6));z-index:var(--layer-2);padding:var(--size-1) var(--size-2);font-size:var(--text-sm);font-family:var(--font-mono);text-align:center}.error.svelte-14miwb5.svelte-14miwb5{box-shadow:var(--shadow-drop);border:solid 1px var(--error-border-color);border-radius:var(--radius-full);background:var(--error-background-fill);padding-right:var(--size-4);padding-left:var(--size-4);color:var(--error-text-color);font-weight:var(--weight-semibold);font-size:var(--text-lg);line-height:var(--line-lg);font-family:var(--font)}.minimal.svelte-14miwb5 .progress-text.svelte-14miwb5{background:var(--block-background-fill)}.border.svelte-14miwb5.svelte-14miwb5{border:1px solid var(--border-color-primary)}.toast-body.svelte-solcu7{display:flex;position:relative;right:0;left:0;align-items:center;margin:var(--size-6) var(--size-4);margin:auto;border-radius:var(--container-radius);overflow:hidden;pointer-events:auto}.toast-body.error.svelte-solcu7{border:1px solid var(--color-red-700);background:var(--color-red-50)}.dark .toast-body.error.svelte-solcu7{border:1px solid var(--color-red-500);background-color:var(--color-grey-950)}.toast-body.warning.svelte-solcu7{border:1px solid var(--color-yellow-700);background:var(--color-yellow-50)}.dark .toast-body.warning.svelte-solcu7{border:1px solid var(--color-yellow-500);background-color:var(--color-grey-950)}.toast-body.info.svelte-solcu7{border:1px solid var(--color-grey-700);background:var(--color-grey-50)}.dark .toast-body.info.svelte-solcu7{border:1px solid var(--color-grey-500);background-color:var(--color-grey-950)}.toast-title.svelte-solcu7{display:flex;align-items:center;font-weight:var(--weight-bold);font-size:var(--text-lg);line-height:var(--line-sm);text-transform:capitalize}.toast-title.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-title.error.svelte-solcu7{color:var(--color-red-50)}.toast-title.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-title.warning.svelte-solcu7{color:var(--color-yellow-50)}.toast-title.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-title.info.svelte-solcu7{color:var(--color-grey-50)}.toast-close.svelte-solcu7{margin:0 var(--size-3);border-radius:var(--size-3);padding:0px var(--size-1-5);font-size:var(--size-5);line-height:var(--size-5)}.toast-close.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-close.error.svelte-solcu7{color:var(--color-red-500)}.toast-close.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-close.warning.svelte-solcu7{color:var(--color-yellow-500)}.toast-close.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-close.info.svelte-solcu7{color:var(--color-grey-500)}.toast-text.svelte-solcu7{font-size:var(--text-lg)}.toast-text.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-text.error.svelte-solcu7{color:var(--color-red-50)}.toast-text.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-text.warning.svelte-solcu7{color:var(--color-yellow-50)}.toast-text.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-text.info.svelte-solcu7{color:var(--color-grey-50)}.toast-details.svelte-solcu7{margin:var(--size-3) var(--size-3) var(--size-3) 0;width:100%}.toast-icon.svelte-solcu7{display:flex;position:absolute;position:relative;flex-shrink:0;justify-content:center;align-items:center;margin:var(--size-2);border-radius:var(--radius-full);padding:var(--size-1);padding-left:calc(var(--size-1) - 1px);width:35px;height:35px}.toast-icon.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-icon.error.svelte-solcu7{color:var(--color-red-500)}.toast-icon.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-icon.warning.svelte-solcu7{color:var(--color-yellow-500)}.toast-icon.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-icon.info.svelte-solcu7{color:var(--color-grey-500)}@keyframes svelte-solcu7-countdown{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.timer.svelte-solcu7{position:absolute;bottom:0;left:0;transform-origin:0 0;animation:svelte-solcu7-countdown 10s linear forwards;width:100%;height:var(--size-1)}.timer.error.svelte-solcu7{background:var(--color-red-700)}.dark .timer.error.svelte-solcu7{background:var(--color-red-500)}.timer.warning.svelte-solcu7{background:var(--color-yellow-700)}.dark .timer.warning.svelte-solcu7{background:var(--color-yellow-500)}.timer.info.svelte-solcu7{background:var(--color-grey-700)}.dark .timer.info.svelte-solcu7{background:var(--color-grey-500)}.toast-wrap.svelte-gatr8h{display:flex;position:fixed;top:var(--size-4);right:var(--size-4);flex-direction:column;align-items:end;gap:var(--size-2);z-index:var(--layer-top);width:calc(100% - var(--size-8))}@media (--screen-sm){.toast-wrap.svelte-gatr8h{width:calc(var(--size-96) + var(--size-10))}}.gallery.svelte-1gecy8w{padding:var(--size-1) var(--size-2)}
|
src/backend/gradio_unifiedaudio/templates/component/wrapper-98f94c21-f7f71f53.js
ADDED
@@ -0,0 +1,2449 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import S from "./__vite-browser-external-2447137e.js";
|
2 |
+
function z(s) {
|
3 |
+
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
4 |
+
}
|
5 |
+
function gt(s) {
|
6 |
+
if (s.__esModule)
|
7 |
+
return s;
|
8 |
+
var e = s.default;
|
9 |
+
if (typeof e == "function") {
|
10 |
+
var t = function r() {
|
11 |
+
return this instanceof r ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments);
|
12 |
+
};
|
13 |
+
t.prototype = e.prototype;
|
14 |
+
} else
|
15 |
+
t = {};
|
16 |
+
return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(s).forEach(function(r) {
|
17 |
+
var i = Object.getOwnPropertyDescriptor(s, r);
|
18 |
+
Object.defineProperty(t, r, i.get ? i : {
|
19 |
+
enumerable: !0,
|
20 |
+
get: function() {
|
21 |
+
return s[r];
|
22 |
+
}
|
23 |
+
});
|
24 |
+
}), t;
|
25 |
+
}
|
26 |
+
const { Duplex: yt } = S;
|
27 |
+
function Oe(s) {
|
28 |
+
s.emit("close");
|
29 |
+
}
|
30 |
+
function vt() {
|
31 |
+
!this.destroyed && this._writableState.finished && this.destroy();
|
32 |
+
}
|
33 |
+
function Qe(s) {
|
34 |
+
this.removeListener("error", Qe), this.destroy(), this.listenerCount("error") === 0 && this.emit("error", s);
|
35 |
+
}
|
36 |
+
function St(s, e) {
|
37 |
+
let t = !0;
|
38 |
+
const r = new yt({
|
39 |
+
...e,
|
40 |
+
autoDestroy: !1,
|
41 |
+
emitClose: !1,
|
42 |
+
objectMode: !1,
|
43 |
+
writableObjectMode: !1
|
44 |
+
});
|
45 |
+
return s.on("message", function(n, o) {
|
46 |
+
const l = !o && r._readableState.objectMode ? n.toString() : n;
|
47 |
+
r.push(l) || s.pause();
|
48 |
+
}), s.once("error", function(n) {
|
49 |
+
r.destroyed || (t = !1, r.destroy(n));
|
50 |
+
}), s.once("close", function() {
|
51 |
+
r.destroyed || r.push(null);
|
52 |
+
}), r._destroy = function(i, n) {
|
53 |
+
if (s.readyState === s.CLOSED) {
|
54 |
+
n(i), process.nextTick(Oe, r);
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
let o = !1;
|
58 |
+
s.once("error", function(f) {
|
59 |
+
o = !0, n(f);
|
60 |
+
}), s.once("close", function() {
|
61 |
+
o || n(i), process.nextTick(Oe, r);
|
62 |
+
}), t && s.terminate();
|
63 |
+
}, r._final = function(i) {
|
64 |
+
if (s.readyState === s.CONNECTING) {
|
65 |
+
s.once("open", function() {
|
66 |
+
r._final(i);
|
67 |
+
});
|
68 |
+
return;
|
69 |
+
}
|
70 |
+
s._socket !== null && (s._socket._writableState.finished ? (i(), r._readableState.endEmitted && r.destroy()) : (s._socket.once("finish", function() {
|
71 |
+
i();
|
72 |
+
}), s.close()));
|
73 |
+
}, r._read = function() {
|
74 |
+
s.isPaused && s.resume();
|
75 |
+
}, r._write = function(i, n, o) {
|
76 |
+
if (s.readyState === s.CONNECTING) {
|
77 |
+
s.once("open", function() {
|
78 |
+
r._write(i, n, o);
|
79 |
+
});
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
s.send(i, o);
|
83 |
+
}, r.on("end", vt), r.on("error", Qe), r;
|
84 |
+
}
|
85 |
+
var Et = St;
|
86 |
+
const Vs = /* @__PURE__ */ z(Et);
|
87 |
+
var te = { exports: {} }, U = {
|
88 |
+
BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
|
89 |
+
EMPTY_BUFFER: Buffer.alloc(0),
|
90 |
+
GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
|
91 |
+
kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
|
92 |
+
kListener: Symbol("kListener"),
|
93 |
+
kStatusCode: Symbol("status-code"),
|
94 |
+
kWebSocket: Symbol("websocket"),
|
95 |
+
NOOP: () => {
|
96 |
+
}
|
97 |
+
}, bt, xt;
|
98 |
+
const { EMPTY_BUFFER: kt } = U, Se = Buffer[Symbol.species];
|
99 |
+
function wt(s, e) {
|
100 |
+
if (s.length === 0)
|
101 |
+
return kt;
|
102 |
+
if (s.length === 1)
|
103 |
+
return s[0];
|
104 |
+
const t = Buffer.allocUnsafe(e);
|
105 |
+
let r = 0;
|
106 |
+
for (let i = 0; i < s.length; i++) {
|
107 |
+
const n = s[i];
|
108 |
+
t.set(n, r), r += n.length;
|
109 |
+
}
|
110 |
+
return r < e ? new Se(t.buffer, t.byteOffset, r) : t;
|
111 |
+
}
|
112 |
+
function Je(s, e, t, r, i) {
|
113 |
+
for (let n = 0; n < i; n++)
|
114 |
+
t[r + n] = s[n] ^ e[n & 3];
|
115 |
+
}
|
116 |
+
function et(s, e) {
|
117 |
+
for (let t = 0; t < s.length; t++)
|
118 |
+
s[t] ^= e[t & 3];
|
119 |
+
}
|
120 |
+
function Ot(s) {
|
121 |
+
return s.length === s.buffer.byteLength ? s.buffer : s.buffer.slice(s.byteOffset, s.byteOffset + s.length);
|
122 |
+
}
|
123 |
+
function Ee(s) {
|
124 |
+
if (Ee.readOnly = !0, Buffer.isBuffer(s))
|
125 |
+
return s;
|
126 |
+
let e;
|
127 |
+
return s instanceof ArrayBuffer ? e = new Se(s) : ArrayBuffer.isView(s) ? e = new Se(s.buffer, s.byteOffset, s.byteLength) : (e = Buffer.from(s), Ee.readOnly = !1), e;
|
128 |
+
}
|
129 |
+
te.exports = {
|
130 |
+
concat: wt,
|
131 |
+
mask: Je,
|
132 |
+
toArrayBuffer: Ot,
|
133 |
+
toBuffer: Ee,
|
134 |
+
unmask: et
|
135 |
+
};
|
136 |
+
if (!process.env.WS_NO_BUFFER_UTIL)
|
137 |
+
try {
|
138 |
+
const s = require("bufferutil");
|
139 |
+
xt = te.exports.mask = function(e, t, r, i, n) {
|
140 |
+
n < 48 ? Je(e, t, r, i, n) : s.mask(e, t, r, i, n);
|
141 |
+
}, bt = te.exports.unmask = function(e, t) {
|
142 |
+
e.length < 32 ? et(e, t) : s.unmask(e, t);
|
143 |
+
};
|
144 |
+
} catch {
|
145 |
+
}
|
146 |
+
var ne = te.exports;
|
147 |
+
const Ce = Symbol("kDone"), ue = Symbol("kRun");
|
148 |
+
let Ct = class {
|
149 |
+
/**
|
150 |
+
* Creates a new `Limiter`.
|
151 |
+
*
|
152 |
+
* @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
|
153 |
+
* to run concurrently
|
154 |
+
*/
|
155 |
+
constructor(e) {
|
156 |
+
this[Ce] = () => {
|
157 |
+
this.pending--, this[ue]();
|
158 |
+
}, this.concurrency = e || 1 / 0, this.jobs = [], this.pending = 0;
|
159 |
+
}
|
160 |
+
/**
|
161 |
+
* Adds a job to the queue.
|
162 |
+
*
|
163 |
+
* @param {Function} job The job to run
|
164 |
+
* @public
|
165 |
+
*/
|
166 |
+
add(e) {
|
167 |
+
this.jobs.push(e), this[ue]();
|
168 |
+
}
|
169 |
+
/**
|
170 |
+
* Removes a job from the queue and runs it if possible.
|
171 |
+
*
|
172 |
+
* @private
|
173 |
+
*/
|
174 |
+
[ue]() {
|
175 |
+
if (this.pending !== this.concurrency && this.jobs.length) {
|
176 |
+
const e = this.jobs.shift();
|
177 |
+
this.pending++, e(this[Ce]);
|
178 |
+
}
|
179 |
+
}
|
180 |
+
};
|
181 |
+
var Tt = Ct;
|
182 |
+
const W = S, Te = ne, Lt = Tt, { kStatusCode: tt } = U, Nt = Buffer[Symbol.species], Pt = Buffer.from([0, 0, 255, 255]), se = Symbol("permessage-deflate"), w = Symbol("total-length"), V = Symbol("callback"), C = Symbol("buffers"), J = Symbol("error");
|
183 |
+
let K, Rt = class {
|
184 |
+
/**
|
185 |
+
* Creates a PerMessageDeflate instance.
|
186 |
+
*
|
187 |
+
* @param {Object} [options] Configuration options
|
188 |
+
* @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support
|
189 |
+
* for, or request, a custom client window size
|
190 |
+
* @param {Boolean} [options.clientNoContextTakeover=false] Advertise/
|
191 |
+
* acknowledge disabling of client context takeover
|
192 |
+
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
193 |
+
* calls to zlib
|
194 |
+
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
195 |
+
* use of a custom server window size
|
196 |
+
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
197 |
+
* disabling of server context takeover
|
198 |
+
* @param {Number} [options.threshold=1024] Size (in bytes) below which
|
199 |
+
* messages should not be compressed if context takeover is disabled
|
200 |
+
* @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on
|
201 |
+
* deflate
|
202 |
+
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
203 |
+
* inflate
|
204 |
+
* @param {Boolean} [isServer=false] Create the instance in either server or
|
205 |
+
* client mode
|
206 |
+
* @param {Number} [maxPayload=0] The maximum allowed message length
|
207 |
+
*/
|
208 |
+
constructor(e, t, r) {
|
209 |
+
if (this._maxPayload = r | 0, this._options = e || {}, this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024, this._isServer = !!t, this._deflate = null, this._inflate = null, this.params = null, !K) {
|
210 |
+
const i = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
|
211 |
+
K = new Lt(i);
|
212 |
+
}
|
213 |
+
}
|
214 |
+
/**
|
215 |
+
* @type {String}
|
216 |
+
*/
|
217 |
+
static get extensionName() {
|
218 |
+
return "permessage-deflate";
|
219 |
+
}
|
220 |
+
/**
|
221 |
+
* Create an extension negotiation offer.
|
222 |
+
*
|
223 |
+
* @return {Object} Extension parameters
|
224 |
+
* @public
|
225 |
+
*/
|
226 |
+
offer() {
|
227 |
+
const e = {};
|
228 |
+
return this._options.serverNoContextTakeover && (e.server_no_context_takeover = !0), this._options.clientNoContextTakeover && (e.client_no_context_takeover = !0), this._options.serverMaxWindowBits && (e.server_max_window_bits = this._options.serverMaxWindowBits), this._options.clientMaxWindowBits ? e.client_max_window_bits = this._options.clientMaxWindowBits : this._options.clientMaxWindowBits == null && (e.client_max_window_bits = !0), e;
|
229 |
+
}
|
230 |
+
/**
|
231 |
+
* Accept an extension negotiation offer/response.
|
232 |
+
*
|
233 |
+
* @param {Array} configurations The extension negotiation offers/reponse
|
234 |
+
* @return {Object} Accepted configuration
|
235 |
+
* @public
|
236 |
+
*/
|
237 |
+
accept(e) {
|
238 |
+
return e = this.normalizeParams(e), this.params = this._isServer ? this.acceptAsServer(e) : this.acceptAsClient(e), this.params;
|
239 |
+
}
|
240 |
+
/**
|
241 |
+
* Releases all resources used by the extension.
|
242 |
+
*
|
243 |
+
* @public
|
244 |
+
*/
|
245 |
+
cleanup() {
|
246 |
+
if (this._inflate && (this._inflate.close(), this._inflate = null), this._deflate) {
|
247 |
+
const e = this._deflate[V];
|
248 |
+
this._deflate.close(), this._deflate = null, e && e(
|
249 |
+
new Error(
|
250 |
+
"The deflate stream was closed while data was being processed"
|
251 |
+
)
|
252 |
+
);
|
253 |
+
}
|
254 |
+
}
|
255 |
+
/**
|
256 |
+
* Accept an extension negotiation offer.
|
257 |
+
*
|
258 |
+
* @param {Array} offers The extension negotiation offers
|
259 |
+
* @return {Object} Accepted configuration
|
260 |
+
* @private
|
261 |
+
*/
|
262 |
+
acceptAsServer(e) {
|
263 |
+
const t = this._options, r = e.find((i) => !(t.serverNoContextTakeover === !1 && i.server_no_context_takeover || i.server_max_window_bits && (t.serverMaxWindowBits === !1 || typeof t.serverMaxWindowBits == "number" && t.serverMaxWindowBits > i.server_max_window_bits) || typeof t.clientMaxWindowBits == "number" && !i.client_max_window_bits));
|
264 |
+
if (!r)
|
265 |
+
throw new Error("None of the extension offers can be accepted");
|
266 |
+
return t.serverNoContextTakeover && (r.server_no_context_takeover = !0), t.clientNoContextTakeover && (r.client_no_context_takeover = !0), typeof t.serverMaxWindowBits == "number" && (r.server_max_window_bits = t.serverMaxWindowBits), typeof t.clientMaxWindowBits == "number" ? r.client_max_window_bits = t.clientMaxWindowBits : (r.client_max_window_bits === !0 || t.clientMaxWindowBits === !1) && delete r.client_max_window_bits, r;
|
267 |
+
}
|
268 |
+
/**
|
269 |
+
* Accept the extension negotiation response.
|
270 |
+
*
|
271 |
+
* @param {Array} response The extension negotiation response
|
272 |
+
* @return {Object} Accepted configuration
|
273 |
+
* @private
|
274 |
+
*/
|
275 |
+
acceptAsClient(e) {
|
276 |
+
const t = e[0];
|
277 |
+
if (this._options.clientNoContextTakeover === !1 && t.client_no_context_takeover)
|
278 |
+
throw new Error('Unexpected parameter "client_no_context_takeover"');
|
279 |
+
if (!t.client_max_window_bits)
|
280 |
+
typeof this._options.clientMaxWindowBits == "number" && (t.client_max_window_bits = this._options.clientMaxWindowBits);
|
281 |
+
else if (this._options.clientMaxWindowBits === !1 || typeof this._options.clientMaxWindowBits == "number" && t.client_max_window_bits > this._options.clientMaxWindowBits)
|
282 |
+
throw new Error(
|
283 |
+
'Unexpected or invalid parameter "client_max_window_bits"'
|
284 |
+
);
|
285 |
+
return t;
|
286 |
+
}
|
287 |
+
/**
|
288 |
+
* Normalize parameters.
|
289 |
+
*
|
290 |
+
* @param {Array} configurations The extension negotiation offers/reponse
|
291 |
+
* @return {Array} The offers/response with normalized parameters
|
292 |
+
* @private
|
293 |
+
*/
|
294 |
+
normalizeParams(e) {
|
295 |
+
return e.forEach((t) => {
|
296 |
+
Object.keys(t).forEach((r) => {
|
297 |
+
let i = t[r];
|
298 |
+
if (i.length > 1)
|
299 |
+
throw new Error(`Parameter "${r}" must have only a single value`);
|
300 |
+
if (i = i[0], r === "client_max_window_bits") {
|
301 |
+
if (i !== !0) {
|
302 |
+
const n = +i;
|
303 |
+
if (!Number.isInteger(n) || n < 8 || n > 15)
|
304 |
+
throw new TypeError(
|
305 |
+
`Invalid value for parameter "${r}": ${i}`
|
306 |
+
);
|
307 |
+
i = n;
|
308 |
+
} else if (!this._isServer)
|
309 |
+
throw new TypeError(
|
310 |
+
`Invalid value for parameter "${r}": ${i}`
|
311 |
+
);
|
312 |
+
} else if (r === "server_max_window_bits") {
|
313 |
+
const n = +i;
|
314 |
+
if (!Number.isInteger(n) || n < 8 || n > 15)
|
315 |
+
throw new TypeError(
|
316 |
+
`Invalid value for parameter "${r}": ${i}`
|
317 |
+
);
|
318 |
+
i = n;
|
319 |
+
} else if (r === "client_no_context_takeover" || r === "server_no_context_takeover") {
|
320 |
+
if (i !== !0)
|
321 |
+
throw new TypeError(
|
322 |
+
`Invalid value for parameter "${r}": ${i}`
|
323 |
+
);
|
324 |
+
} else
|
325 |
+
throw new Error(`Unknown parameter "${r}"`);
|
326 |
+
t[r] = i;
|
327 |
+
});
|
328 |
+
}), e;
|
329 |
+
}
|
330 |
+
/**
|
331 |
+
* Decompress data. Concurrency limited.
|
332 |
+
*
|
333 |
+
* @param {Buffer} data Compressed data
|
334 |
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
335 |
+
* @param {Function} callback Callback
|
336 |
+
* @public
|
337 |
+
*/
|
338 |
+
decompress(e, t, r) {
|
339 |
+
K.add((i) => {
|
340 |
+
this._decompress(e, t, (n, o) => {
|
341 |
+
i(), r(n, o);
|
342 |
+
});
|
343 |
+
});
|
344 |
+
}
|
345 |
+
/**
|
346 |
+
* Compress data. Concurrency limited.
|
347 |
+
*
|
348 |
+
* @param {(Buffer|String)} data Data to compress
|
349 |
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
350 |
+
* @param {Function} callback Callback
|
351 |
+
* @public
|
352 |
+
*/
|
353 |
+
compress(e, t, r) {
|
354 |
+
K.add((i) => {
|
355 |
+
this._compress(e, t, (n, o) => {
|
356 |
+
i(), r(n, o);
|
357 |
+
});
|
358 |
+
});
|
359 |
+
}
|
360 |
+
/**
|
361 |
+
* Decompress data.
|
362 |
+
*
|
363 |
+
* @param {Buffer} data Compressed data
|
364 |
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
365 |
+
* @param {Function} callback Callback
|
366 |
+
* @private
|
367 |
+
*/
|
368 |
+
_decompress(e, t, r) {
|
369 |
+
const i = this._isServer ? "client" : "server";
|
370 |
+
if (!this._inflate) {
|
371 |
+
const n = `${i}_max_window_bits`, o = typeof this.params[n] != "number" ? W.Z_DEFAULT_WINDOWBITS : this.params[n];
|
372 |
+
this._inflate = W.createInflateRaw({
|
373 |
+
...this._options.zlibInflateOptions,
|
374 |
+
windowBits: o
|
375 |
+
}), this._inflate[se] = this, this._inflate[w] = 0, this._inflate[C] = [], this._inflate.on("error", Bt), this._inflate.on("data", st);
|
376 |
+
}
|
377 |
+
this._inflate[V] = r, this._inflate.write(e), t && this._inflate.write(Pt), this._inflate.flush(() => {
|
378 |
+
const n = this._inflate[J];
|
379 |
+
if (n) {
|
380 |
+
this._inflate.close(), this._inflate = null, r(n);
|
381 |
+
return;
|
382 |
+
}
|
383 |
+
const o = Te.concat(
|
384 |
+
this._inflate[C],
|
385 |
+
this._inflate[w]
|
386 |
+
);
|
387 |
+
this._inflate._readableState.endEmitted ? (this._inflate.close(), this._inflate = null) : (this._inflate[w] = 0, this._inflate[C] = [], t && this.params[`${i}_no_context_takeover`] && this._inflate.reset()), r(null, o);
|
388 |
+
});
|
389 |
+
}
|
390 |
+
/**
|
391 |
+
* Compress data.
|
392 |
+
*
|
393 |
+
* @param {(Buffer|String)} data Data to compress
|
394 |
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
395 |
+
* @param {Function} callback Callback
|
396 |
+
* @private
|
397 |
+
*/
|
398 |
+
_compress(e, t, r) {
|
399 |
+
const i = this._isServer ? "server" : "client";
|
400 |
+
if (!this._deflate) {
|
401 |
+
const n = `${i}_max_window_bits`, o = typeof this.params[n] != "number" ? W.Z_DEFAULT_WINDOWBITS : this.params[n];
|
402 |
+
this._deflate = W.createDeflateRaw({
|
403 |
+
...this._options.zlibDeflateOptions,
|
404 |
+
windowBits: o
|
405 |
+
}), this._deflate[w] = 0, this._deflate[C] = [], this._deflate.on("data", Ut);
|
406 |
+
}
|
407 |
+
this._deflate[V] = r, this._deflate.write(e), this._deflate.flush(W.Z_SYNC_FLUSH, () => {
|
408 |
+
if (!this._deflate)
|
409 |
+
return;
|
410 |
+
let n = Te.concat(
|
411 |
+
this._deflate[C],
|
412 |
+
this._deflate[w]
|
413 |
+
);
|
414 |
+
t && (n = new Nt(n.buffer, n.byteOffset, n.length - 4)), this._deflate[V] = null, this._deflate[w] = 0, this._deflate[C] = [], t && this.params[`${i}_no_context_takeover`] && this._deflate.reset(), r(null, n);
|
415 |
+
});
|
416 |
+
}
|
417 |
+
};
|
418 |
+
var oe = Rt;
|
419 |
+
function Ut(s) {
|
420 |
+
this[C].push(s), this[w] += s.length;
|
421 |
+
}
|
422 |
+
function st(s) {
|
423 |
+
if (this[w] += s.length, this[se]._maxPayload < 1 || this[w] <= this[se]._maxPayload) {
|
424 |
+
this[C].push(s);
|
425 |
+
return;
|
426 |
+
}
|
427 |
+
this[J] = new RangeError("Max payload size exceeded"), this[J].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH", this[J][tt] = 1009, this.removeListener("data", st), this.reset();
|
428 |
+
}
|
429 |
+
function Bt(s) {
|
430 |
+
this[se]._inflate = null, s[tt] = 1007, this[V](s);
|
431 |
+
}
|
432 |
+
var re = { exports: {} };
|
433 |
+
const $t = {}, Mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
434 |
+
__proto__: null,
|
435 |
+
default: $t
|
436 |
+
}, Symbol.toStringTag, { value: "Module" })), It = /* @__PURE__ */ gt(Mt);
|
437 |
+
var Le;
|
438 |
+
const { isUtf8: Ne } = S, Dt = [
|
439 |
+
0,
|
440 |
+
0,
|
441 |
+
0,
|
442 |
+
0,
|
443 |
+
0,
|
444 |
+
0,
|
445 |
+
0,
|
446 |
+
0,
|
447 |
+
0,
|
448 |
+
0,
|
449 |
+
0,
|
450 |
+
0,
|
451 |
+
0,
|
452 |
+
0,
|
453 |
+
0,
|
454 |
+
0,
|
455 |
+
// 0 - 15
|
456 |
+
0,
|
457 |
+
0,
|
458 |
+
0,
|
459 |
+
0,
|
460 |
+
0,
|
461 |
+
0,
|
462 |
+
0,
|
463 |
+
0,
|
464 |
+
0,
|
465 |
+
0,
|
466 |
+
0,
|
467 |
+
0,
|
468 |
+
0,
|
469 |
+
0,
|
470 |
+
0,
|
471 |
+
0,
|
472 |
+
// 16 - 31
|
473 |
+
0,
|
474 |
+
1,
|
475 |
+
0,
|
476 |
+
1,
|
477 |
+
1,
|
478 |
+
1,
|
479 |
+
1,
|
480 |
+
1,
|
481 |
+
0,
|
482 |
+
0,
|
483 |
+
1,
|
484 |
+
1,
|
485 |
+
0,
|
486 |
+
1,
|
487 |
+
1,
|
488 |
+
0,
|
489 |
+
// 32 - 47
|
490 |
+
1,
|
491 |
+
1,
|
492 |
+
1,
|
493 |
+
1,
|
494 |
+
1,
|
495 |
+
1,
|
496 |
+
1,
|
497 |
+
1,
|
498 |
+
1,
|
499 |
+
1,
|
500 |
+
0,
|
501 |
+
0,
|
502 |
+
0,
|
503 |
+
0,
|
504 |
+
0,
|
505 |
+
0,
|
506 |
+
// 48 - 63
|
507 |
+
0,
|
508 |
+
1,
|
509 |
+
1,
|
510 |
+
1,
|
511 |
+
1,
|
512 |
+
1,
|
513 |
+
1,
|
514 |
+
1,
|
515 |
+
1,
|
516 |
+
1,
|
517 |
+
1,
|
518 |
+
1,
|
519 |
+
1,
|
520 |
+
1,
|
521 |
+
1,
|
522 |
+
1,
|
523 |
+
// 64 - 79
|
524 |
+
1,
|
525 |
+
1,
|
526 |
+
1,
|
527 |
+
1,
|
528 |
+
1,
|
529 |
+
1,
|
530 |
+
1,
|
531 |
+
1,
|
532 |
+
1,
|
533 |
+
1,
|
534 |
+
1,
|
535 |
+
0,
|
536 |
+
0,
|
537 |
+
0,
|
538 |
+
1,
|
539 |
+
1,
|
540 |
+
// 80 - 95
|
541 |
+
1,
|
542 |
+
1,
|
543 |
+
1,
|
544 |
+
1,
|
545 |
+
1,
|
546 |
+
1,
|
547 |
+
1,
|
548 |
+
1,
|
549 |
+
1,
|
550 |
+
1,
|
551 |
+
1,
|
552 |
+
1,
|
553 |
+
1,
|
554 |
+
1,
|
555 |
+
1,
|
556 |
+
1,
|
557 |
+
// 96 - 111
|
558 |
+
1,
|
559 |
+
1,
|
560 |
+
1,
|
561 |
+
1,
|
562 |
+
1,
|
563 |
+
1,
|
564 |
+
1,
|
565 |
+
1,
|
566 |
+
1,
|
567 |
+
1,
|
568 |
+
1,
|
569 |
+
0,
|
570 |
+
1,
|
571 |
+
0,
|
572 |
+
1,
|
573 |
+
0
|
574 |
+
// 112 - 127
|
575 |
+
];
|
576 |
+
function Wt(s) {
|
577 |
+
return s >= 1e3 && s <= 1014 && s !== 1004 && s !== 1005 && s !== 1006 || s >= 3e3 && s <= 4999;
|
578 |
+
}
|
579 |
+
function be(s) {
|
580 |
+
const e = s.length;
|
581 |
+
let t = 0;
|
582 |
+
for (; t < e; )
|
583 |
+
if (!(s[t] & 128))
|
584 |
+
t++;
|
585 |
+
else if ((s[t] & 224) === 192) {
|
586 |
+
if (t + 1 === e || (s[t + 1] & 192) !== 128 || (s[t] & 254) === 192)
|
587 |
+
return !1;
|
588 |
+
t += 2;
|
589 |
+
} else if ((s[t] & 240) === 224) {
|
590 |
+
if (t + 2 >= e || (s[t + 1] & 192) !== 128 || (s[t + 2] & 192) !== 128 || s[t] === 224 && (s[t + 1] & 224) === 128 || // Overlong
|
591 |
+
s[t] === 237 && (s[t + 1] & 224) === 160)
|
592 |
+
return !1;
|
593 |
+
t += 3;
|
594 |
+
} else if ((s[t] & 248) === 240) {
|
595 |
+
if (t + 3 >= e || (s[t + 1] & 192) !== 128 || (s[t + 2] & 192) !== 128 || (s[t + 3] & 192) !== 128 || s[t] === 240 && (s[t + 1] & 240) === 128 || // Overlong
|
596 |
+
s[t] === 244 && s[t + 1] > 143 || s[t] > 244)
|
597 |
+
return !1;
|
598 |
+
t += 4;
|
599 |
+
} else
|
600 |
+
return !1;
|
601 |
+
return !0;
|
602 |
+
}
|
603 |
+
re.exports = {
|
604 |
+
isValidStatusCode: Wt,
|
605 |
+
isValidUTF8: be,
|
606 |
+
tokenChars: Dt
|
607 |
+
};
|
608 |
+
if (Ne)
|
609 |
+
Le = re.exports.isValidUTF8 = function(s) {
|
610 |
+
return s.length < 24 ? be(s) : Ne(s);
|
611 |
+
};
|
612 |
+
else if (!process.env.WS_NO_UTF_8_VALIDATE)
|
613 |
+
try {
|
614 |
+
const s = It;
|
615 |
+
Le = re.exports.isValidUTF8 = function(e) {
|
616 |
+
return e.length < 32 ? be(e) : s(e);
|
617 |
+
};
|
618 |
+
} catch {
|
619 |
+
}
|
620 |
+
var ae = re.exports;
|
621 |
+
const { Writable: At } = S, Pe = oe, {
|
622 |
+
BINARY_TYPES: Ft,
|
623 |
+
EMPTY_BUFFER: Re,
|
624 |
+
kStatusCode: jt,
|
625 |
+
kWebSocket: Gt
|
626 |
+
} = U, { concat: de, toArrayBuffer: Vt, unmask: Ht } = ne, { isValidStatusCode: zt, isValidUTF8: Ue } = ae, X = Buffer[Symbol.species], A = 0, Be = 1, $e = 2, Me = 3, _e = 4, Yt = 5;
|
627 |
+
let qt = class extends At {
|
628 |
+
/**
|
629 |
+
* Creates a Receiver instance.
|
630 |
+
*
|
631 |
+
* @param {Object} [options] Options object
|
632 |
+
* @param {String} [options.binaryType=nodebuffer] The type for binary data
|
633 |
+
* @param {Object} [options.extensions] An object containing the negotiated
|
634 |
+
* extensions
|
635 |
+
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
|
636 |
+
* client or server mode
|
637 |
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
638 |
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
639 |
+
* not to skip UTF-8 validation for text and close messages
|
640 |
+
*/
|
641 |
+
constructor(e = {}) {
|
642 |
+
super(), this._binaryType = e.binaryType || Ft[0], this._extensions = e.extensions || {}, this._isServer = !!e.isServer, this._maxPayload = e.maxPayload | 0, this._skipUTF8Validation = !!e.skipUTF8Validation, this[Gt] = void 0, this._bufferedBytes = 0, this._buffers = [], this._compressed = !1, this._payloadLength = 0, this._mask = void 0, this._fragmented = 0, this._masked = !1, this._fin = !1, this._opcode = 0, this._totalPayloadLength = 0, this._messageLength = 0, this._fragments = [], this._state = A, this._loop = !1;
|
643 |
+
}
|
644 |
+
/**
|
645 |
+
* Implements `Writable.prototype._write()`.
|
646 |
+
*
|
647 |
+
* @param {Buffer} chunk The chunk of data to write
|
648 |
+
* @param {String} encoding The character encoding of `chunk`
|
649 |
+
* @param {Function} cb Callback
|
650 |
+
* @private
|
651 |
+
*/
|
652 |
+
_write(e, t, r) {
|
653 |
+
if (this._opcode === 8 && this._state == A)
|
654 |
+
return r();
|
655 |
+
this._bufferedBytes += e.length, this._buffers.push(e), this.startLoop(r);
|
656 |
+
}
|
657 |
+
/**
|
658 |
+
* Consumes `n` bytes from the buffered data.
|
659 |
+
*
|
660 |
+
* @param {Number} n The number of bytes to consume
|
661 |
+
* @return {Buffer} The consumed bytes
|
662 |
+
* @private
|
663 |
+
*/
|
664 |
+
consume(e) {
|
665 |
+
if (this._bufferedBytes -= e, e === this._buffers[0].length)
|
666 |
+
return this._buffers.shift();
|
667 |
+
if (e < this._buffers[0].length) {
|
668 |
+
const r = this._buffers[0];
|
669 |
+
return this._buffers[0] = new X(
|
670 |
+
r.buffer,
|
671 |
+
r.byteOffset + e,
|
672 |
+
r.length - e
|
673 |
+
), new X(r.buffer, r.byteOffset, e);
|
674 |
+
}
|
675 |
+
const t = Buffer.allocUnsafe(e);
|
676 |
+
do {
|
677 |
+
const r = this._buffers[0], i = t.length - e;
|
678 |
+
e >= r.length ? t.set(this._buffers.shift(), i) : (t.set(new Uint8Array(r.buffer, r.byteOffset, e), i), this._buffers[0] = new X(
|
679 |
+
r.buffer,
|
680 |
+
r.byteOffset + e,
|
681 |
+
r.length - e
|
682 |
+
)), e -= r.length;
|
683 |
+
} while (e > 0);
|
684 |
+
return t;
|
685 |
+
}
|
686 |
+
/**
|
687 |
+
* Starts the parsing loop.
|
688 |
+
*
|
689 |
+
* @param {Function} cb Callback
|
690 |
+
* @private
|
691 |
+
*/
|
692 |
+
startLoop(e) {
|
693 |
+
let t;
|
694 |
+
this._loop = !0;
|
695 |
+
do
|
696 |
+
switch (this._state) {
|
697 |
+
case A:
|
698 |
+
t = this.getInfo();
|
699 |
+
break;
|
700 |
+
case Be:
|
701 |
+
t = this.getPayloadLength16();
|
702 |
+
break;
|
703 |
+
case $e:
|
704 |
+
t = this.getPayloadLength64();
|
705 |
+
break;
|
706 |
+
case Me:
|
707 |
+
this.getMask();
|
708 |
+
break;
|
709 |
+
case _e:
|
710 |
+
t = this.getData(e);
|
711 |
+
break;
|
712 |
+
default:
|
713 |
+
this._loop = !1;
|
714 |
+
return;
|
715 |
+
}
|
716 |
+
while (this._loop);
|
717 |
+
e(t);
|
718 |
+
}
|
719 |
+
/**
|
720 |
+
* Reads the first two bytes of a frame.
|
721 |
+
*
|
722 |
+
* @return {(RangeError|undefined)} A possible error
|
723 |
+
* @private
|
724 |
+
*/
|
725 |
+
getInfo() {
|
726 |
+
if (this._bufferedBytes < 2) {
|
727 |
+
this._loop = !1;
|
728 |
+
return;
|
729 |
+
}
|
730 |
+
const e = this.consume(2);
|
731 |
+
if (e[0] & 48)
|
732 |
+
return this._loop = !1, g(
|
733 |
+
RangeError,
|
734 |
+
"RSV2 and RSV3 must be clear",
|
735 |
+
!0,
|
736 |
+
1002,
|
737 |
+
"WS_ERR_UNEXPECTED_RSV_2_3"
|
738 |
+
);
|
739 |
+
const t = (e[0] & 64) === 64;
|
740 |
+
if (t && !this._extensions[Pe.extensionName])
|
741 |
+
return this._loop = !1, g(
|
742 |
+
RangeError,
|
743 |
+
"RSV1 must be clear",
|
744 |
+
!0,
|
745 |
+
1002,
|
746 |
+
"WS_ERR_UNEXPECTED_RSV_1"
|
747 |
+
);
|
748 |
+
if (this._fin = (e[0] & 128) === 128, this._opcode = e[0] & 15, this._payloadLength = e[1] & 127, this._opcode === 0) {
|
749 |
+
if (t)
|
750 |
+
return this._loop = !1, g(
|
751 |
+
RangeError,
|
752 |
+
"RSV1 must be clear",
|
753 |
+
!0,
|
754 |
+
1002,
|
755 |
+
"WS_ERR_UNEXPECTED_RSV_1"
|
756 |
+
);
|
757 |
+
if (!this._fragmented)
|
758 |
+
return this._loop = !1, g(
|
759 |
+
RangeError,
|
760 |
+
"invalid opcode 0",
|
761 |
+
!0,
|
762 |
+
1002,
|
763 |
+
"WS_ERR_INVALID_OPCODE"
|
764 |
+
);
|
765 |
+
this._opcode = this._fragmented;
|
766 |
+
} else if (this._opcode === 1 || this._opcode === 2) {
|
767 |
+
if (this._fragmented)
|
768 |
+
return this._loop = !1, g(
|
769 |
+
RangeError,
|
770 |
+
`invalid opcode ${this._opcode}`,
|
771 |
+
!0,
|
772 |
+
1002,
|
773 |
+
"WS_ERR_INVALID_OPCODE"
|
774 |
+
);
|
775 |
+
this._compressed = t;
|
776 |
+
} else if (this._opcode > 7 && this._opcode < 11) {
|
777 |
+
if (!this._fin)
|
778 |
+
return this._loop = !1, g(
|
779 |
+
RangeError,
|
780 |
+
"FIN must be set",
|
781 |
+
!0,
|
782 |
+
1002,
|
783 |
+
"WS_ERR_EXPECTED_FIN"
|
784 |
+
);
|
785 |
+
if (t)
|
786 |
+
return this._loop = !1, g(
|
787 |
+
RangeError,
|
788 |
+
"RSV1 must be clear",
|
789 |
+
!0,
|
790 |
+
1002,
|
791 |
+
"WS_ERR_UNEXPECTED_RSV_1"
|
792 |
+
);
|
793 |
+
if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1)
|
794 |
+
return this._loop = !1, g(
|
795 |
+
RangeError,
|
796 |
+
`invalid payload length ${this._payloadLength}`,
|
797 |
+
!0,
|
798 |
+
1002,
|
799 |
+
"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"
|
800 |
+
);
|
801 |
+
} else
|
802 |
+
return this._loop = !1, g(
|
803 |
+
RangeError,
|
804 |
+
`invalid opcode ${this._opcode}`,
|
805 |
+
!0,
|
806 |
+
1002,
|
807 |
+
"WS_ERR_INVALID_OPCODE"
|
808 |
+
);
|
809 |
+
if (!this._fin && !this._fragmented && (this._fragmented = this._opcode), this._masked = (e[1] & 128) === 128, this._isServer) {
|
810 |
+
if (!this._masked)
|
811 |
+
return this._loop = !1, g(
|
812 |
+
RangeError,
|
813 |
+
"MASK must be set",
|
814 |
+
!0,
|
815 |
+
1002,
|
816 |
+
"WS_ERR_EXPECTED_MASK"
|
817 |
+
);
|
818 |
+
} else if (this._masked)
|
819 |
+
return this._loop = !1, g(
|
820 |
+
RangeError,
|
821 |
+
"MASK must be clear",
|
822 |
+
!0,
|
823 |
+
1002,
|
824 |
+
"WS_ERR_UNEXPECTED_MASK"
|
825 |
+
);
|
826 |
+
if (this._payloadLength === 126)
|
827 |
+
this._state = Be;
|
828 |
+
else if (this._payloadLength === 127)
|
829 |
+
this._state = $e;
|
830 |
+
else
|
831 |
+
return this.haveLength();
|
832 |
+
}
|
833 |
+
/**
|
834 |
+
* Gets extended payload length (7+16).
|
835 |
+
*
|
836 |
+
* @return {(RangeError|undefined)} A possible error
|
837 |
+
* @private
|
838 |
+
*/
|
839 |
+
getPayloadLength16() {
|
840 |
+
if (this._bufferedBytes < 2) {
|
841 |
+
this._loop = !1;
|
842 |
+
return;
|
843 |
+
}
|
844 |
+
return this._payloadLength = this.consume(2).readUInt16BE(0), this.haveLength();
|
845 |
+
}
|
846 |
+
/**
|
847 |
+
* Gets extended payload length (7+64).
|
848 |
+
*
|
849 |
+
* @return {(RangeError|undefined)} A possible error
|
850 |
+
* @private
|
851 |
+
*/
|
852 |
+
getPayloadLength64() {
|
853 |
+
if (this._bufferedBytes < 8) {
|
854 |
+
this._loop = !1;
|
855 |
+
return;
|
856 |
+
}
|
857 |
+
const e = this.consume(8), t = e.readUInt32BE(0);
|
858 |
+
return t > Math.pow(2, 53 - 32) - 1 ? (this._loop = !1, g(
|
859 |
+
RangeError,
|
860 |
+
"Unsupported WebSocket frame: payload length > 2^53 - 1",
|
861 |
+
!1,
|
862 |
+
1009,
|
863 |
+
"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"
|
864 |
+
)) : (this._payloadLength = t * Math.pow(2, 32) + e.readUInt32BE(4), this.haveLength());
|
865 |
+
}
|
866 |
+
/**
|
867 |
+
* Payload length has been read.
|
868 |
+
*
|
869 |
+
* @return {(RangeError|undefined)} A possible error
|
870 |
+
* @private
|
871 |
+
*/
|
872 |
+
haveLength() {
|
873 |
+
if (this._payloadLength && this._opcode < 8 && (this._totalPayloadLength += this._payloadLength, this._totalPayloadLength > this._maxPayload && this._maxPayload > 0))
|
874 |
+
return this._loop = !1, g(
|
875 |
+
RangeError,
|
876 |
+
"Max payload size exceeded",
|
877 |
+
!1,
|
878 |
+
1009,
|
879 |
+
"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
|
880 |
+
);
|
881 |
+
this._masked ? this._state = Me : this._state = _e;
|
882 |
+
}
|
883 |
+
/**
|
884 |
+
* Reads mask bytes.
|
885 |
+
*
|
886 |
+
* @private
|
887 |
+
*/
|
888 |
+
getMask() {
|
889 |
+
if (this._bufferedBytes < 4) {
|
890 |
+
this._loop = !1;
|
891 |
+
return;
|
892 |
+
}
|
893 |
+
this._mask = this.consume(4), this._state = _e;
|
894 |
+
}
|
895 |
+
/**
|
896 |
+
* Reads data bytes.
|
897 |
+
*
|
898 |
+
* @param {Function} cb Callback
|
899 |
+
* @return {(Error|RangeError|undefined)} A possible error
|
900 |
+
* @private
|
901 |
+
*/
|
902 |
+
getData(e) {
|
903 |
+
let t = Re;
|
904 |
+
if (this._payloadLength) {
|
905 |
+
if (this._bufferedBytes < this._payloadLength) {
|
906 |
+
this._loop = !1;
|
907 |
+
return;
|
908 |
+
}
|
909 |
+
t = this.consume(this._payloadLength), this._masked && this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3] && Ht(t, this._mask);
|
910 |
+
}
|
911 |
+
if (this._opcode > 7)
|
912 |
+
return this.controlMessage(t);
|
913 |
+
if (this._compressed) {
|
914 |
+
this._state = Yt, this.decompress(t, e);
|
915 |
+
return;
|
916 |
+
}
|
917 |
+
return t.length && (this._messageLength = this._totalPayloadLength, this._fragments.push(t)), this.dataMessage();
|
918 |
+
}
|
919 |
+
/**
|
920 |
+
* Decompresses data.
|
921 |
+
*
|
922 |
+
* @param {Buffer} data Compressed data
|
923 |
+
* @param {Function} cb Callback
|
924 |
+
* @private
|
925 |
+
*/
|
926 |
+
decompress(e, t) {
|
927 |
+
this._extensions[Pe.extensionName].decompress(e, this._fin, (i, n) => {
|
928 |
+
if (i)
|
929 |
+
return t(i);
|
930 |
+
if (n.length) {
|
931 |
+
if (this._messageLength += n.length, this._messageLength > this._maxPayload && this._maxPayload > 0)
|
932 |
+
return t(
|
933 |
+
g(
|
934 |
+
RangeError,
|
935 |
+
"Max payload size exceeded",
|
936 |
+
!1,
|
937 |
+
1009,
|
938 |
+
"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
|
939 |
+
)
|
940 |
+
);
|
941 |
+
this._fragments.push(n);
|
942 |
+
}
|
943 |
+
const o = this.dataMessage();
|
944 |
+
if (o)
|
945 |
+
return t(o);
|
946 |
+
this.startLoop(t);
|
947 |
+
});
|
948 |
+
}
|
949 |
+
/**
|
950 |
+
* Handles a data message.
|
951 |
+
*
|
952 |
+
* @return {(Error|undefined)} A possible error
|
953 |
+
* @private
|
954 |
+
*/
|
955 |
+
dataMessage() {
|
956 |
+
if (this._fin) {
|
957 |
+
const e = this._messageLength, t = this._fragments;
|
958 |
+
if (this._totalPayloadLength = 0, this._messageLength = 0, this._fragmented = 0, this._fragments = [], this._opcode === 2) {
|
959 |
+
let r;
|
960 |
+
this._binaryType === "nodebuffer" ? r = de(t, e) : this._binaryType === "arraybuffer" ? r = Vt(de(t, e)) : r = t, this.emit("message", r, !0);
|
961 |
+
} else {
|
962 |
+
const r = de(t, e);
|
963 |
+
if (!this._skipUTF8Validation && !Ue(r))
|
964 |
+
return this._loop = !1, g(
|
965 |
+
Error,
|
966 |
+
"invalid UTF-8 sequence",
|
967 |
+
!0,
|
968 |
+
1007,
|
969 |
+
"WS_ERR_INVALID_UTF8"
|
970 |
+
);
|
971 |
+
this.emit("message", r, !1);
|
972 |
+
}
|
973 |
+
}
|
974 |
+
this._state = A;
|
975 |
+
}
|
976 |
+
/**
|
977 |
+
* Handles a control message.
|
978 |
+
*
|
979 |
+
* @param {Buffer} data Data to handle
|
980 |
+
* @return {(Error|RangeError|undefined)} A possible error
|
981 |
+
* @private
|
982 |
+
*/
|
983 |
+
controlMessage(e) {
|
984 |
+
if (this._opcode === 8)
|
985 |
+
if (this._loop = !1, e.length === 0)
|
986 |
+
this.emit("conclude", 1005, Re), this.end();
|
987 |
+
else {
|
988 |
+
const t = e.readUInt16BE(0);
|
989 |
+
if (!zt(t))
|
990 |
+
return g(
|
991 |
+
RangeError,
|
992 |
+
`invalid status code ${t}`,
|
993 |
+
!0,
|
994 |
+
1002,
|
995 |
+
"WS_ERR_INVALID_CLOSE_CODE"
|
996 |
+
);
|
997 |
+
const r = new X(
|
998 |
+
e.buffer,
|
999 |
+
e.byteOffset + 2,
|
1000 |
+
e.length - 2
|
1001 |
+
);
|
1002 |
+
if (!this._skipUTF8Validation && !Ue(r))
|
1003 |
+
return g(
|
1004 |
+
Error,
|
1005 |
+
"invalid UTF-8 sequence",
|
1006 |
+
!0,
|
1007 |
+
1007,
|
1008 |
+
"WS_ERR_INVALID_UTF8"
|
1009 |
+
);
|
1010 |
+
this.emit("conclude", t, r), this.end();
|
1011 |
+
}
|
1012 |
+
else
|
1013 |
+
this._opcode === 9 ? this.emit("ping", e) : this.emit("pong", e);
|
1014 |
+
this._state = A;
|
1015 |
+
}
|
1016 |
+
};
|
1017 |
+
var rt = qt;
|
1018 |
+
function g(s, e, t, r, i) {
|
1019 |
+
const n = new s(
|
1020 |
+
t ? `Invalid WebSocket frame: ${e}` : e
|
1021 |
+
);
|
1022 |
+
return Error.captureStackTrace(n, g), n.code = i, n[jt] = r, n;
|
1023 |
+
}
|
1024 |
+
const qs = /* @__PURE__ */ z(rt), { randomFillSync: Kt } = S, Ie = oe, { EMPTY_BUFFER: Xt } = U, { isValidStatusCode: Zt } = ae, { mask: De, toBuffer: M } = ne, x = Symbol("kByteLength"), Qt = Buffer.alloc(4);
|
1025 |
+
let Jt = class P {
|
1026 |
+
/**
|
1027 |
+
* Creates a Sender instance.
|
1028 |
+
*
|
1029 |
+
* @param {(net.Socket|tls.Socket)} socket The connection socket
|
1030 |
+
* @param {Object} [extensions] An object containing the negotiated extensions
|
1031 |
+
* @param {Function} [generateMask] The function used to generate the masking
|
1032 |
+
* key
|
1033 |
+
*/
|
1034 |
+
constructor(e, t, r) {
|
1035 |
+
this._extensions = t || {}, r && (this._generateMask = r, this._maskBuffer = Buffer.alloc(4)), this._socket = e, this._firstFragment = !0, this._compress = !1, this._bufferedBytes = 0, this._deflating = !1, this._queue = [];
|
1036 |
+
}
|
1037 |
+
/**
|
1038 |
+
* Frames a piece of data according to the HyBi WebSocket protocol.
|
1039 |
+
*
|
1040 |
+
* @param {(Buffer|String)} data The data to frame
|
1041 |
+
* @param {Object} options Options object
|
1042 |
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
1043 |
+
* FIN bit
|
1044 |
+
* @param {Function} [options.generateMask] The function used to generate the
|
1045 |
+
* masking key
|
1046 |
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
1047 |
+
* `data`
|
1048 |
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
1049 |
+
* key
|
1050 |
+
* @param {Number} options.opcode The opcode
|
1051 |
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
1052 |
+
* modified
|
1053 |
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
1054 |
+
* RSV1 bit
|
1055 |
+
* @return {(Buffer|String)[]} The framed data
|
1056 |
+
* @public
|
1057 |
+
*/
|
1058 |
+
static frame(e, t) {
|
1059 |
+
let r, i = !1, n = 2, o = !1;
|
1060 |
+
t.mask && (r = t.maskBuffer || Qt, t.generateMask ? t.generateMask(r) : Kt(r, 0, 4), o = (r[0] | r[1] | r[2] | r[3]) === 0, n = 6);
|
1061 |
+
let l;
|
1062 |
+
typeof e == "string" ? (!t.mask || o) && t[x] !== void 0 ? l = t[x] : (e = Buffer.from(e), l = e.length) : (l = e.length, i = t.mask && t.readOnly && !o);
|
1063 |
+
let f = l;
|
1064 |
+
l >= 65536 ? (n += 8, f = 127) : l > 125 && (n += 2, f = 126);
|
1065 |
+
const a = Buffer.allocUnsafe(i ? l + n : n);
|
1066 |
+
return a[0] = t.fin ? t.opcode | 128 : t.opcode, t.rsv1 && (a[0] |= 64), a[1] = f, f === 126 ? a.writeUInt16BE(l, 2) : f === 127 && (a[2] = a[3] = 0, a.writeUIntBE(l, 4, 6)), t.mask ? (a[1] |= 128, a[n - 4] = r[0], a[n - 3] = r[1], a[n - 2] = r[2], a[n - 1] = r[3], o ? [a, e] : i ? (De(e, r, a, n, l), [a]) : (De(e, r, e, 0, l), [a, e])) : [a, e];
|
1067 |
+
}
|
1068 |
+
/**
|
1069 |
+
* Sends a close message to the other peer.
|
1070 |
+
*
|
1071 |
+
* @param {Number} [code] The status code component of the body
|
1072 |
+
* @param {(String|Buffer)} [data] The message component of the body
|
1073 |
+
* @param {Boolean} [mask=false] Specifies whether or not to mask the message
|
1074 |
+
* @param {Function} [cb] Callback
|
1075 |
+
* @public
|
1076 |
+
*/
|
1077 |
+
close(e, t, r, i) {
|
1078 |
+
let n;
|
1079 |
+
if (e === void 0)
|
1080 |
+
n = Xt;
|
1081 |
+
else {
|
1082 |
+
if (typeof e != "number" || !Zt(e))
|
1083 |
+
throw new TypeError("First argument must be a valid error code number");
|
1084 |
+
if (t === void 0 || !t.length)
|
1085 |
+
n = Buffer.allocUnsafe(2), n.writeUInt16BE(e, 0);
|
1086 |
+
else {
|
1087 |
+
const l = Buffer.byteLength(t);
|
1088 |
+
if (l > 123)
|
1089 |
+
throw new RangeError("The message must not be greater than 123 bytes");
|
1090 |
+
n = Buffer.allocUnsafe(2 + l), n.writeUInt16BE(e, 0), typeof t == "string" ? n.write(t, 2) : n.set(t, 2);
|
1091 |
+
}
|
1092 |
+
}
|
1093 |
+
const o = {
|
1094 |
+
[x]: n.length,
|
1095 |
+
fin: !0,
|
1096 |
+
generateMask: this._generateMask,
|
1097 |
+
mask: r,
|
1098 |
+
maskBuffer: this._maskBuffer,
|
1099 |
+
opcode: 8,
|
1100 |
+
readOnly: !1,
|
1101 |
+
rsv1: !1
|
1102 |
+
};
|
1103 |
+
this._deflating ? this.enqueue([this.dispatch, n, !1, o, i]) : this.sendFrame(P.frame(n, o), i);
|
1104 |
+
}
|
1105 |
+
/**
|
1106 |
+
* Sends a ping message to the other peer.
|
1107 |
+
*
|
1108 |
+
* @param {*} data The message to send
|
1109 |
+
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
1110 |
+
* @param {Function} [cb] Callback
|
1111 |
+
* @public
|
1112 |
+
*/
|
1113 |
+
ping(e, t, r) {
|
1114 |
+
let i, n;
|
1115 |
+
if (typeof e == "string" ? (i = Buffer.byteLength(e), n = !1) : (e = M(e), i = e.length, n = M.readOnly), i > 125)
|
1116 |
+
throw new RangeError("The data size must not be greater than 125 bytes");
|
1117 |
+
const o = {
|
1118 |
+
[x]: i,
|
1119 |
+
fin: !0,
|
1120 |
+
generateMask: this._generateMask,
|
1121 |
+
mask: t,
|
1122 |
+
maskBuffer: this._maskBuffer,
|
1123 |
+
opcode: 9,
|
1124 |
+
readOnly: n,
|
1125 |
+
rsv1: !1
|
1126 |
+
};
|
1127 |
+
this._deflating ? this.enqueue([this.dispatch, e, !1, o, r]) : this.sendFrame(P.frame(e, o), r);
|
1128 |
+
}
|
1129 |
+
/**
|
1130 |
+
* Sends a pong message to the other peer.
|
1131 |
+
*
|
1132 |
+
* @param {*} data The message to send
|
1133 |
+
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
1134 |
+
* @param {Function} [cb] Callback
|
1135 |
+
* @public
|
1136 |
+
*/
|
1137 |
+
pong(e, t, r) {
|
1138 |
+
let i, n;
|
1139 |
+
if (typeof e == "string" ? (i = Buffer.byteLength(e), n = !1) : (e = M(e), i = e.length, n = M.readOnly), i > 125)
|
1140 |
+
throw new RangeError("The data size must not be greater than 125 bytes");
|
1141 |
+
const o = {
|
1142 |
+
[x]: i,
|
1143 |
+
fin: !0,
|
1144 |
+
generateMask: this._generateMask,
|
1145 |
+
mask: t,
|
1146 |
+
maskBuffer: this._maskBuffer,
|
1147 |
+
opcode: 10,
|
1148 |
+
readOnly: n,
|
1149 |
+
rsv1: !1
|
1150 |
+
};
|
1151 |
+
this._deflating ? this.enqueue([this.dispatch, e, !1, o, r]) : this.sendFrame(P.frame(e, o), r);
|
1152 |
+
}
|
1153 |
+
/**
|
1154 |
+
* Sends a data message to the other peer.
|
1155 |
+
*
|
1156 |
+
* @param {*} data The message to send
|
1157 |
+
* @param {Object} options Options object
|
1158 |
+
* @param {Boolean} [options.binary=false] Specifies whether `data` is binary
|
1159 |
+
* or text
|
1160 |
+
* @param {Boolean} [options.compress=false] Specifies whether or not to
|
1161 |
+
* compress `data`
|
1162 |
+
* @param {Boolean} [options.fin=false] Specifies whether the fragment is the
|
1163 |
+
* last one
|
1164 |
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
1165 |
+
* `data`
|
1166 |
+
* @param {Function} [cb] Callback
|
1167 |
+
* @public
|
1168 |
+
*/
|
1169 |
+
send(e, t, r) {
|
1170 |
+
const i = this._extensions[Ie.extensionName];
|
1171 |
+
let n = t.binary ? 2 : 1, o = t.compress, l, f;
|
1172 |
+
if (typeof e == "string" ? (l = Buffer.byteLength(e), f = !1) : (e = M(e), l = e.length, f = M.readOnly), this._firstFragment ? (this._firstFragment = !1, o && i && i.params[i._isServer ? "server_no_context_takeover" : "client_no_context_takeover"] && (o = l >= i._threshold), this._compress = o) : (o = !1, n = 0), t.fin && (this._firstFragment = !0), i) {
|
1173 |
+
const a = {
|
1174 |
+
[x]: l,
|
1175 |
+
fin: t.fin,
|
1176 |
+
generateMask: this._generateMask,
|
1177 |
+
mask: t.mask,
|
1178 |
+
maskBuffer: this._maskBuffer,
|
1179 |
+
opcode: n,
|
1180 |
+
readOnly: f,
|
1181 |
+
rsv1: o
|
1182 |
+
};
|
1183 |
+
this._deflating ? this.enqueue([this.dispatch, e, this._compress, a, r]) : this.dispatch(e, this._compress, a, r);
|
1184 |
+
} else
|
1185 |
+
this.sendFrame(
|
1186 |
+
P.frame(e, {
|
1187 |
+
[x]: l,
|
1188 |
+
fin: t.fin,
|
1189 |
+
generateMask: this._generateMask,
|
1190 |
+
mask: t.mask,
|
1191 |
+
maskBuffer: this._maskBuffer,
|
1192 |
+
opcode: n,
|
1193 |
+
readOnly: f,
|
1194 |
+
rsv1: !1
|
1195 |
+
}),
|
1196 |
+
r
|
1197 |
+
);
|
1198 |
+
}
|
1199 |
+
/**
|
1200 |
+
* Dispatches a message.
|
1201 |
+
*
|
1202 |
+
* @param {(Buffer|String)} data The message to send
|
1203 |
+
* @param {Boolean} [compress=false] Specifies whether or not to compress
|
1204 |
+
* `data`
|
1205 |
+
* @param {Object} options Options object
|
1206 |
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
1207 |
+
* FIN bit
|
1208 |
+
* @param {Function} [options.generateMask] The function used to generate the
|
1209 |
+
* masking key
|
1210 |
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
1211 |
+
* `data`
|
1212 |
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
1213 |
+
* key
|
1214 |
+
* @param {Number} options.opcode The opcode
|
1215 |
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
1216 |
+
* modified
|
1217 |
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
1218 |
+
* RSV1 bit
|
1219 |
+
* @param {Function} [cb] Callback
|
1220 |
+
* @private
|
1221 |
+
*/
|
1222 |
+
dispatch(e, t, r, i) {
|
1223 |
+
if (!t) {
|
1224 |
+
this.sendFrame(P.frame(e, r), i);
|
1225 |
+
return;
|
1226 |
+
}
|
1227 |
+
const n = this._extensions[Ie.extensionName];
|
1228 |
+
this._bufferedBytes += r[x], this._deflating = !0, n.compress(e, r.fin, (o, l) => {
|
1229 |
+
if (this._socket.destroyed) {
|
1230 |
+
const f = new Error(
|
1231 |
+
"The socket was closed while data was being compressed"
|
1232 |
+
);
|
1233 |
+
typeof i == "function" && i(f);
|
1234 |
+
for (let a = 0; a < this._queue.length; a++) {
|
1235 |
+
const c = this._queue[a], h = c[c.length - 1];
|
1236 |
+
typeof h == "function" && h(f);
|
1237 |
+
}
|
1238 |
+
return;
|
1239 |
+
}
|
1240 |
+
this._bufferedBytes -= r[x], this._deflating = !1, r.readOnly = !1, this.sendFrame(P.frame(l, r), i), this.dequeue();
|
1241 |
+
});
|
1242 |
+
}
|
1243 |
+
/**
|
1244 |
+
* Executes queued send operations.
|
1245 |
+
*
|
1246 |
+
* @private
|
1247 |
+
*/
|
1248 |
+
dequeue() {
|
1249 |
+
for (; !this._deflating && this._queue.length; ) {
|
1250 |
+
const e = this._queue.shift();
|
1251 |
+
this._bufferedBytes -= e[3][x], Reflect.apply(e[0], this, e.slice(1));
|
1252 |
+
}
|
1253 |
+
}
|
1254 |
+
/**
|
1255 |
+
* Enqueues a send operation.
|
1256 |
+
*
|
1257 |
+
* @param {Array} params Send operation parameters.
|
1258 |
+
* @private
|
1259 |
+
*/
|
1260 |
+
enqueue(e) {
|
1261 |
+
this._bufferedBytes += e[3][x], this._queue.push(e);
|
1262 |
+
}
|
1263 |
+
/**
|
1264 |
+
* Sends a frame.
|
1265 |
+
*
|
1266 |
+
* @param {Buffer[]} list The frame to send
|
1267 |
+
* @param {Function} [cb] Callback
|
1268 |
+
* @private
|
1269 |
+
*/
|
1270 |
+
sendFrame(e, t) {
|
1271 |
+
e.length === 2 ? (this._socket.cork(), this._socket.write(e[0]), this._socket.write(e[1], t), this._socket.uncork()) : this._socket.write(e[0], t);
|
1272 |
+
}
|
1273 |
+
};
|
1274 |
+
var it = Jt;
|
1275 |
+
const Ks = /* @__PURE__ */ z(it), { kForOnEventAttribute: F, kListener: pe } = U, We = Symbol("kCode"), Ae = Symbol("kData"), Fe = Symbol("kError"), je = Symbol("kMessage"), Ge = Symbol("kReason"), I = Symbol("kTarget"), Ve = Symbol("kType"), He = Symbol("kWasClean");
|
1276 |
+
class B {
|
1277 |
+
/**
|
1278 |
+
* Create a new `Event`.
|
1279 |
+
*
|
1280 |
+
* @param {String} type The name of the event
|
1281 |
+
* @throws {TypeError} If the `type` argument is not specified
|
1282 |
+
*/
|
1283 |
+
constructor(e) {
|
1284 |
+
this[I] = null, this[Ve] = e;
|
1285 |
+
}
|
1286 |
+
/**
|
1287 |
+
* @type {*}
|
1288 |
+
*/
|
1289 |
+
get target() {
|
1290 |
+
return this[I];
|
1291 |
+
}
|
1292 |
+
/**
|
1293 |
+
* @type {String}
|
1294 |
+
*/
|
1295 |
+
get type() {
|
1296 |
+
return this[Ve];
|
1297 |
+
}
|
1298 |
+
}
|
1299 |
+
Object.defineProperty(B.prototype, "target", { enumerable: !0 });
|
1300 |
+
Object.defineProperty(B.prototype, "type", { enumerable: !0 });
|
1301 |
+
class Y extends B {
|
1302 |
+
/**
|
1303 |
+
* Create a new `CloseEvent`.
|
1304 |
+
*
|
1305 |
+
* @param {String} type The name of the event
|
1306 |
+
* @param {Object} [options] A dictionary object that allows for setting
|
1307 |
+
* attributes via object members of the same name
|
1308 |
+
* @param {Number} [options.code=0] The status code explaining why the
|
1309 |
+
* connection was closed
|
1310 |
+
* @param {String} [options.reason=''] A human-readable string explaining why
|
1311 |
+
* the connection was closed
|
1312 |
+
* @param {Boolean} [options.wasClean=false] Indicates whether or not the
|
1313 |
+
* connection was cleanly closed
|
1314 |
+
*/
|
1315 |
+
constructor(e, t = {}) {
|
1316 |
+
super(e), this[We] = t.code === void 0 ? 0 : t.code, this[Ge] = t.reason === void 0 ? "" : t.reason, this[He] = t.wasClean === void 0 ? !1 : t.wasClean;
|
1317 |
+
}
|
1318 |
+
/**
|
1319 |
+
* @type {Number}
|
1320 |
+
*/
|
1321 |
+
get code() {
|
1322 |
+
return this[We];
|
1323 |
+
}
|
1324 |
+
/**
|
1325 |
+
* @type {String}
|
1326 |
+
*/
|
1327 |
+
get reason() {
|
1328 |
+
return this[Ge];
|
1329 |
+
}
|
1330 |
+
/**
|
1331 |
+
* @type {Boolean}
|
1332 |
+
*/
|
1333 |
+
get wasClean() {
|
1334 |
+
return this[He];
|
1335 |
+
}
|
1336 |
+
}
|
1337 |
+
Object.defineProperty(Y.prototype, "code", { enumerable: !0 });
|
1338 |
+
Object.defineProperty(Y.prototype, "reason", { enumerable: !0 });
|
1339 |
+
Object.defineProperty(Y.prototype, "wasClean", { enumerable: !0 });
|
1340 |
+
class le extends B {
|
1341 |
+
/**
|
1342 |
+
* Create a new `ErrorEvent`.
|
1343 |
+
*
|
1344 |
+
* @param {String} type The name of the event
|
1345 |
+
* @param {Object} [options] A dictionary object that allows for setting
|
1346 |
+
* attributes via object members of the same name
|
1347 |
+
* @param {*} [options.error=null] The error that generated this event
|
1348 |
+
* @param {String} [options.message=''] The error message
|
1349 |
+
*/
|
1350 |
+
constructor(e, t = {}) {
|
1351 |
+
super(e), this[Fe] = t.error === void 0 ? null : t.error, this[je] = t.message === void 0 ? "" : t.message;
|
1352 |
+
}
|
1353 |
+
/**
|
1354 |
+
* @type {*}
|
1355 |
+
*/
|
1356 |
+
get error() {
|
1357 |
+
return this[Fe];
|
1358 |
+
}
|
1359 |
+
/**
|
1360 |
+
* @type {String}
|
1361 |
+
*/
|
1362 |
+
get message() {
|
1363 |
+
return this[je];
|
1364 |
+
}
|
1365 |
+
}
|
1366 |
+
Object.defineProperty(le.prototype, "error", { enumerable: !0 });
|
1367 |
+
Object.defineProperty(le.prototype, "message", { enumerable: !0 });
|
1368 |
+
class xe extends B {
|
1369 |
+
/**
|
1370 |
+
* Create a new `MessageEvent`.
|
1371 |
+
*
|
1372 |
+
* @param {String} type The name of the event
|
1373 |
+
* @param {Object} [options] A dictionary object that allows for setting
|
1374 |
+
* attributes via object members of the same name
|
1375 |
+
* @param {*} [options.data=null] The message content
|
1376 |
+
*/
|
1377 |
+
constructor(e, t = {}) {
|
1378 |
+
super(e), this[Ae] = t.data === void 0 ? null : t.data;
|
1379 |
+
}
|
1380 |
+
/**
|
1381 |
+
* @type {*}
|
1382 |
+
*/
|
1383 |
+
get data() {
|
1384 |
+
return this[Ae];
|
1385 |
+
}
|
1386 |
+
}
|
1387 |
+
Object.defineProperty(xe.prototype, "data", { enumerable: !0 });
|
1388 |
+
const es = {
|
1389 |
+
/**
|
1390 |
+
* Register an event listener.
|
1391 |
+
*
|
1392 |
+
* @param {String} type A string representing the event type to listen for
|
1393 |
+
* @param {(Function|Object)} handler The listener to add
|
1394 |
+
* @param {Object} [options] An options object specifies characteristics about
|
1395 |
+
* the event listener
|
1396 |
+
* @param {Boolean} [options.once=false] A `Boolean` indicating that the
|
1397 |
+
* listener should be invoked at most once after being added. If `true`,
|
1398 |
+
* the listener would be automatically removed when invoked.
|
1399 |
+
* @public
|
1400 |
+
*/
|
1401 |
+
addEventListener(s, e, t = {}) {
|
1402 |
+
for (const i of this.listeners(s))
|
1403 |
+
if (!t[F] && i[pe] === e && !i[F])
|
1404 |
+
return;
|
1405 |
+
let r;
|
1406 |
+
if (s === "message")
|
1407 |
+
r = function(n, o) {
|
1408 |
+
const l = new xe("message", {
|
1409 |
+
data: o ? n : n.toString()
|
1410 |
+
});
|
1411 |
+
l[I] = this, Z(e, this, l);
|
1412 |
+
};
|
1413 |
+
else if (s === "close")
|
1414 |
+
r = function(n, o) {
|
1415 |
+
const l = new Y("close", {
|
1416 |
+
code: n,
|
1417 |
+
reason: o.toString(),
|
1418 |
+
wasClean: this._closeFrameReceived && this._closeFrameSent
|
1419 |
+
});
|
1420 |
+
l[I] = this, Z(e, this, l);
|
1421 |
+
};
|
1422 |
+
else if (s === "error")
|
1423 |
+
r = function(n) {
|
1424 |
+
const o = new le("error", {
|
1425 |
+
error: n,
|
1426 |
+
message: n.message
|
1427 |
+
});
|
1428 |
+
o[I] = this, Z(e, this, o);
|
1429 |
+
};
|
1430 |
+
else if (s === "open")
|
1431 |
+
r = function() {
|
1432 |
+
const n = new B("open");
|
1433 |
+
n[I] = this, Z(e, this, n);
|
1434 |
+
};
|
1435 |
+
else
|
1436 |
+
return;
|
1437 |
+
r[F] = !!t[F], r[pe] = e, t.once ? this.once(s, r) : this.on(s, r);
|
1438 |
+
},
|
1439 |
+
/**
|
1440 |
+
* Remove an event listener.
|
1441 |
+
*
|
1442 |
+
* @param {String} type A string representing the event type to remove
|
1443 |
+
* @param {(Function|Object)} handler The listener to remove
|
1444 |
+
* @public
|
1445 |
+
*/
|
1446 |
+
removeEventListener(s, e) {
|
1447 |
+
for (const t of this.listeners(s))
|
1448 |
+
if (t[pe] === e && !t[F]) {
|
1449 |
+
this.removeListener(s, t);
|
1450 |
+
break;
|
1451 |
+
}
|
1452 |
+
}
|
1453 |
+
};
|
1454 |
+
var ts = {
|
1455 |
+
CloseEvent: Y,
|
1456 |
+
ErrorEvent: le,
|
1457 |
+
Event: B,
|
1458 |
+
EventTarget: es,
|
1459 |
+
MessageEvent: xe
|
1460 |
+
};
|
1461 |
+
function Z(s, e, t) {
|
1462 |
+
typeof s == "object" && s.handleEvent ? s.handleEvent.call(s, t) : s.call(e, t);
|
1463 |
+
}
|
1464 |
+
const { tokenChars: j } = ae;
|
1465 |
+
function k(s, e, t) {
|
1466 |
+
s[e] === void 0 ? s[e] = [t] : s[e].push(t);
|
1467 |
+
}
|
1468 |
+
function ss(s) {
|
1469 |
+
const e = /* @__PURE__ */ Object.create(null);
|
1470 |
+
let t = /* @__PURE__ */ Object.create(null), r = !1, i = !1, n = !1, o, l, f = -1, a = -1, c = -1, h = 0;
|
1471 |
+
for (; h < s.length; h++)
|
1472 |
+
if (a = s.charCodeAt(h), o === void 0)
|
1473 |
+
if (c === -1 && j[a] === 1)
|
1474 |
+
f === -1 && (f = h);
|
1475 |
+
else if (h !== 0 && (a === 32 || a === 9))
|
1476 |
+
c === -1 && f !== -1 && (c = h);
|
1477 |
+
else if (a === 59 || a === 44) {
|
1478 |
+
if (f === -1)
|
1479 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1480 |
+
c === -1 && (c = h);
|
1481 |
+
const v = s.slice(f, c);
|
1482 |
+
a === 44 ? (k(e, v, t), t = /* @__PURE__ */ Object.create(null)) : o = v, f = c = -1;
|
1483 |
+
} else
|
1484 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1485 |
+
else if (l === void 0)
|
1486 |
+
if (c === -1 && j[a] === 1)
|
1487 |
+
f === -1 && (f = h);
|
1488 |
+
else if (a === 32 || a === 9)
|
1489 |
+
c === -1 && f !== -1 && (c = h);
|
1490 |
+
else if (a === 59 || a === 44) {
|
1491 |
+
if (f === -1)
|
1492 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1493 |
+
c === -1 && (c = h), k(t, s.slice(f, c), !0), a === 44 && (k(e, o, t), t = /* @__PURE__ */ Object.create(null), o = void 0), f = c = -1;
|
1494 |
+
} else if (a === 61 && f !== -1 && c === -1)
|
1495 |
+
l = s.slice(f, h), f = c = -1;
|
1496 |
+
else
|
1497 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1498 |
+
else if (i) {
|
1499 |
+
if (j[a] !== 1)
|
1500 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1501 |
+
f === -1 ? f = h : r || (r = !0), i = !1;
|
1502 |
+
} else if (n)
|
1503 |
+
if (j[a] === 1)
|
1504 |
+
f === -1 && (f = h);
|
1505 |
+
else if (a === 34 && f !== -1)
|
1506 |
+
n = !1, c = h;
|
1507 |
+
else if (a === 92)
|
1508 |
+
i = !0;
|
1509 |
+
else
|
1510 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1511 |
+
else if (a === 34 && s.charCodeAt(h - 1) === 61)
|
1512 |
+
n = !0;
|
1513 |
+
else if (c === -1 && j[a] === 1)
|
1514 |
+
f === -1 && (f = h);
|
1515 |
+
else if (f !== -1 && (a === 32 || a === 9))
|
1516 |
+
c === -1 && (c = h);
|
1517 |
+
else if (a === 59 || a === 44) {
|
1518 |
+
if (f === -1)
|
1519 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1520 |
+
c === -1 && (c = h);
|
1521 |
+
let v = s.slice(f, c);
|
1522 |
+
r && (v = v.replace(/\\/g, ""), r = !1), k(t, l, v), a === 44 && (k(e, o, t), t = /* @__PURE__ */ Object.create(null), o = void 0), l = void 0, f = c = -1;
|
1523 |
+
} else
|
1524 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1525 |
+
if (f === -1 || n || a === 32 || a === 9)
|
1526 |
+
throw new SyntaxError("Unexpected end of input");
|
1527 |
+
c === -1 && (c = h);
|
1528 |
+
const p = s.slice(f, c);
|
1529 |
+
return o === void 0 ? k(e, p, t) : (l === void 0 ? k(t, p, !0) : r ? k(t, l, p.replace(/\\/g, "")) : k(t, l, p), k(e, o, t)), e;
|
1530 |
+
}
|
1531 |
+
function rs(s) {
|
1532 |
+
return Object.keys(s).map((e) => {
|
1533 |
+
let t = s[e];
|
1534 |
+
return Array.isArray(t) || (t = [t]), t.map((r) => [e].concat(
|
1535 |
+
Object.keys(r).map((i) => {
|
1536 |
+
let n = r[i];
|
1537 |
+
return Array.isArray(n) || (n = [n]), n.map((o) => o === !0 ? i : `${i}=${o}`).join("; ");
|
1538 |
+
})
|
1539 |
+
).join("; ")).join(", ");
|
1540 |
+
}).join(", ");
|
1541 |
+
}
|
1542 |
+
var nt = { format: rs, parse: ss };
|
1543 |
+
const is = S, ns = S, os = S, ot = S, as = S, { randomBytes: ls, createHash: fs } = S, { URL: me } = S, T = oe, hs = rt, cs = it, {
|
1544 |
+
BINARY_TYPES: ze,
|
1545 |
+
EMPTY_BUFFER: Q,
|
1546 |
+
GUID: us,
|
1547 |
+
kForOnEventAttribute: ge,
|
1548 |
+
kListener: ds,
|
1549 |
+
kStatusCode: _s,
|
1550 |
+
kWebSocket: y,
|
1551 |
+
NOOP: at
|
1552 |
+
} = U, {
|
1553 |
+
EventTarget: { addEventListener: ps, removeEventListener: ms }
|
1554 |
+
} = ts, { format: gs, parse: ys } = nt, { toBuffer: vs } = ne, Ss = 30 * 1e3, lt = Symbol("kAborted"), ye = [8, 13], O = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"], Es = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
1555 |
+
let m = class d extends is {
|
1556 |
+
/**
|
1557 |
+
* Create a new `WebSocket`.
|
1558 |
+
*
|
1559 |
+
* @param {(String|URL)} address The URL to which to connect
|
1560 |
+
* @param {(String|String[])} [protocols] The subprotocols
|
1561 |
+
* @param {Object} [options] Connection options
|
1562 |
+
*/
|
1563 |
+
constructor(e, t, r) {
|
1564 |
+
super(), this._binaryType = ze[0], this._closeCode = 1006, this._closeFrameReceived = !1, this._closeFrameSent = !1, this._closeMessage = Q, this._closeTimer = null, this._extensions = {}, this._paused = !1, this._protocol = "", this._readyState = d.CONNECTING, this._receiver = null, this._sender = null, this._socket = null, e !== null ? (this._bufferedAmount = 0, this._isServer = !1, this._redirects = 0, t === void 0 ? t = [] : Array.isArray(t) || (typeof t == "object" && t !== null ? (r = t, t = []) : t = [t]), ht(this, e, t, r)) : this._isServer = !0;
|
1565 |
+
}
|
1566 |
+
/**
|
1567 |
+
* This deviates from the WHATWG interface since ws doesn't support the
|
1568 |
+
* required default "blob" type (instead we define a custom "nodebuffer"
|
1569 |
+
* type).
|
1570 |
+
*
|
1571 |
+
* @type {String}
|
1572 |
+
*/
|
1573 |
+
get binaryType() {
|
1574 |
+
return this._binaryType;
|
1575 |
+
}
|
1576 |
+
set binaryType(e) {
|
1577 |
+
ze.includes(e) && (this._binaryType = e, this._receiver && (this._receiver._binaryType = e));
|
1578 |
+
}
|
1579 |
+
/**
|
1580 |
+
* @type {Number}
|
1581 |
+
*/
|
1582 |
+
get bufferedAmount() {
|
1583 |
+
return this._socket ? this._socket._writableState.length + this._sender._bufferedBytes : this._bufferedAmount;
|
1584 |
+
}
|
1585 |
+
/**
|
1586 |
+
* @type {String}
|
1587 |
+
*/
|
1588 |
+
get extensions() {
|
1589 |
+
return Object.keys(this._extensions).join();
|
1590 |
+
}
|
1591 |
+
/**
|
1592 |
+
* @type {Boolean}
|
1593 |
+
*/
|
1594 |
+
get isPaused() {
|
1595 |
+
return this._paused;
|
1596 |
+
}
|
1597 |
+
/**
|
1598 |
+
* @type {Function}
|
1599 |
+
*/
|
1600 |
+
/* istanbul ignore next */
|
1601 |
+
get onclose() {
|
1602 |
+
return null;
|
1603 |
+
}
|
1604 |
+
/**
|
1605 |
+
* @type {Function}
|
1606 |
+
*/
|
1607 |
+
/* istanbul ignore next */
|
1608 |
+
get onerror() {
|
1609 |
+
return null;
|
1610 |
+
}
|
1611 |
+
/**
|
1612 |
+
* @type {Function}
|
1613 |
+
*/
|
1614 |
+
/* istanbul ignore next */
|
1615 |
+
get onopen() {
|
1616 |
+
return null;
|
1617 |
+
}
|
1618 |
+
/**
|
1619 |
+
* @type {Function}
|
1620 |
+
*/
|
1621 |
+
/* istanbul ignore next */
|
1622 |
+
get onmessage() {
|
1623 |
+
return null;
|
1624 |
+
}
|
1625 |
+
/**
|
1626 |
+
* @type {String}
|
1627 |
+
*/
|
1628 |
+
get protocol() {
|
1629 |
+
return this._protocol;
|
1630 |
+
}
|
1631 |
+
/**
|
1632 |
+
* @type {Number}
|
1633 |
+
*/
|
1634 |
+
get readyState() {
|
1635 |
+
return this._readyState;
|
1636 |
+
}
|
1637 |
+
/**
|
1638 |
+
* @type {String}
|
1639 |
+
*/
|
1640 |
+
get url() {
|
1641 |
+
return this._url;
|
1642 |
+
}
|
1643 |
+
/**
|
1644 |
+
* Set up the socket and the internal resources.
|
1645 |
+
*
|
1646 |
+
* @param {(net.Socket|tls.Socket)} socket The network socket between the
|
1647 |
+
* server and client
|
1648 |
+
* @param {Buffer} head The first packet of the upgraded stream
|
1649 |
+
* @param {Object} options Options object
|
1650 |
+
* @param {Function} [options.generateMask] The function used to generate the
|
1651 |
+
* masking key
|
1652 |
+
* @param {Number} [options.maxPayload=0] The maximum allowed message size
|
1653 |
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
1654 |
+
* not to skip UTF-8 validation for text and close messages
|
1655 |
+
* @private
|
1656 |
+
*/
|
1657 |
+
setSocket(e, t, r) {
|
1658 |
+
const i = new hs({
|
1659 |
+
binaryType: this.binaryType,
|
1660 |
+
extensions: this._extensions,
|
1661 |
+
isServer: this._isServer,
|
1662 |
+
maxPayload: r.maxPayload,
|
1663 |
+
skipUTF8Validation: r.skipUTF8Validation
|
1664 |
+
});
|
1665 |
+
this._sender = new cs(e, this._extensions, r.generateMask), this._receiver = i, this._socket = e, i[y] = this, e[y] = this, i.on("conclude", ks), i.on("drain", ws), i.on("error", Os), i.on("message", Cs), i.on("ping", Ts), i.on("pong", Ls), e.setTimeout(0), e.setNoDelay(), t.length > 0 && e.unshift(t), e.on("close", ut), e.on("data", fe), e.on("end", dt), e.on("error", _t), this._readyState = d.OPEN, this.emit("open");
|
1666 |
+
}
|
1667 |
+
/**
|
1668 |
+
* Emit the `'close'` event.
|
1669 |
+
*
|
1670 |
+
* @private
|
1671 |
+
*/
|
1672 |
+
emitClose() {
|
1673 |
+
if (!this._socket) {
|
1674 |
+
this._readyState = d.CLOSED, this.emit("close", this._closeCode, this._closeMessage);
|
1675 |
+
return;
|
1676 |
+
}
|
1677 |
+
this._extensions[T.extensionName] && this._extensions[T.extensionName].cleanup(), this._receiver.removeAllListeners(), this._readyState = d.CLOSED, this.emit("close", this._closeCode, this._closeMessage);
|
1678 |
+
}
|
1679 |
+
/**
|
1680 |
+
* Start a closing handshake.
|
1681 |
+
*
|
1682 |
+
* +----------+ +-----------+ +----------+
|
1683 |
+
* - - -|ws.close()|-->|close frame|-->|ws.close()|- - -
|
1684 |
+
* | +----------+ +-----------+ +----------+ |
|
1685 |
+
* +----------+ +-----------+ |
|
1686 |
+
* CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING
|
1687 |
+
* +----------+ +-----------+ |
|
1688 |
+
* | | | +---+ |
|
1689 |
+
* +------------------------+-->|fin| - - - -
|
1690 |
+
* | +---+ | +---+
|
1691 |
+
* - - - - -|fin|<---------------------+
|
1692 |
+
* +---+
|
1693 |
+
*
|
1694 |
+
* @param {Number} [code] Status code explaining why the connection is closing
|
1695 |
+
* @param {(String|Buffer)} [data] The reason why the connection is
|
1696 |
+
* closing
|
1697 |
+
* @public
|
1698 |
+
*/
|
1699 |
+
close(e, t) {
|
1700 |
+
if (this.readyState !== d.CLOSED) {
|
1701 |
+
if (this.readyState === d.CONNECTING) {
|
1702 |
+
const r = "WebSocket was closed before the connection was established";
|
1703 |
+
b(this, this._req, r);
|
1704 |
+
return;
|
1705 |
+
}
|
1706 |
+
if (this.readyState === d.CLOSING) {
|
1707 |
+
this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end();
|
1708 |
+
return;
|
1709 |
+
}
|
1710 |
+
this._readyState = d.CLOSING, this._sender.close(e, t, !this._isServer, (r) => {
|
1711 |
+
r || (this._closeFrameSent = !0, (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end());
|
1712 |
+
}), this._closeTimer = setTimeout(
|
1713 |
+
this._socket.destroy.bind(this._socket),
|
1714 |
+
Ss
|
1715 |
+
);
|
1716 |
+
}
|
1717 |
+
}
|
1718 |
+
/**
|
1719 |
+
* Pause the socket.
|
1720 |
+
*
|
1721 |
+
* @public
|
1722 |
+
*/
|
1723 |
+
pause() {
|
1724 |
+
this.readyState === d.CONNECTING || this.readyState === d.CLOSED || (this._paused = !0, this._socket.pause());
|
1725 |
+
}
|
1726 |
+
/**
|
1727 |
+
* Send a ping.
|
1728 |
+
*
|
1729 |
+
* @param {*} [data] The data to send
|
1730 |
+
* @param {Boolean} [mask] Indicates whether or not to mask `data`
|
1731 |
+
* @param {Function} [cb] Callback which is executed when the ping is sent
|
1732 |
+
* @public
|
1733 |
+
*/
|
1734 |
+
ping(e, t, r) {
|
1735 |
+
if (this.readyState === d.CONNECTING)
|
1736 |
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
1737 |
+
if (typeof e == "function" ? (r = e, e = t = void 0) : typeof t == "function" && (r = t, t = void 0), typeof e == "number" && (e = e.toString()), this.readyState !== d.OPEN) {
|
1738 |
+
ve(this, e, r);
|
1739 |
+
return;
|
1740 |
+
}
|
1741 |
+
t === void 0 && (t = !this._isServer), this._sender.ping(e || Q, t, r);
|
1742 |
+
}
|
1743 |
+
/**
|
1744 |
+
* Send a pong.
|
1745 |
+
*
|
1746 |
+
* @param {*} [data] The data to send
|
1747 |
+
* @param {Boolean} [mask] Indicates whether or not to mask `data`
|
1748 |
+
* @param {Function} [cb] Callback which is executed when the pong is sent
|
1749 |
+
* @public
|
1750 |
+
*/
|
1751 |
+
pong(e, t, r) {
|
1752 |
+
if (this.readyState === d.CONNECTING)
|
1753 |
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
1754 |
+
if (typeof e == "function" ? (r = e, e = t = void 0) : typeof t == "function" && (r = t, t = void 0), typeof e == "number" && (e = e.toString()), this.readyState !== d.OPEN) {
|
1755 |
+
ve(this, e, r);
|
1756 |
+
return;
|
1757 |
+
}
|
1758 |
+
t === void 0 && (t = !this._isServer), this._sender.pong(e || Q, t, r);
|
1759 |
+
}
|
1760 |
+
/**
|
1761 |
+
* Resume the socket.
|
1762 |
+
*
|
1763 |
+
* @public
|
1764 |
+
*/
|
1765 |
+
resume() {
|
1766 |
+
this.readyState === d.CONNECTING || this.readyState === d.CLOSED || (this._paused = !1, this._receiver._writableState.needDrain || this._socket.resume());
|
1767 |
+
}
|
1768 |
+
/**
|
1769 |
+
* Send a data message.
|
1770 |
+
*
|
1771 |
+
* @param {*} data The message to send
|
1772 |
+
* @param {Object} [options] Options object
|
1773 |
+
* @param {Boolean} [options.binary] Specifies whether `data` is binary or
|
1774 |
+
* text
|
1775 |
+
* @param {Boolean} [options.compress] Specifies whether or not to compress
|
1776 |
+
* `data`
|
1777 |
+
* @param {Boolean} [options.fin=true] Specifies whether the fragment is the
|
1778 |
+
* last one
|
1779 |
+
* @param {Boolean} [options.mask] Specifies whether or not to mask `data`
|
1780 |
+
* @param {Function} [cb] Callback which is executed when data is written out
|
1781 |
+
* @public
|
1782 |
+
*/
|
1783 |
+
send(e, t, r) {
|
1784 |
+
if (this.readyState === d.CONNECTING)
|
1785 |
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
1786 |
+
if (typeof t == "function" && (r = t, t = {}), typeof e == "number" && (e = e.toString()), this.readyState !== d.OPEN) {
|
1787 |
+
ve(this, e, r);
|
1788 |
+
return;
|
1789 |
+
}
|
1790 |
+
const i = {
|
1791 |
+
binary: typeof e != "string",
|
1792 |
+
mask: !this._isServer,
|
1793 |
+
compress: !0,
|
1794 |
+
fin: !0,
|
1795 |
+
...t
|
1796 |
+
};
|
1797 |
+
this._extensions[T.extensionName] || (i.compress = !1), this._sender.send(e || Q, i, r);
|
1798 |
+
}
|
1799 |
+
/**
|
1800 |
+
* Forcibly close the connection.
|
1801 |
+
*
|
1802 |
+
* @public
|
1803 |
+
*/
|
1804 |
+
terminate() {
|
1805 |
+
if (this.readyState !== d.CLOSED) {
|
1806 |
+
if (this.readyState === d.CONNECTING) {
|
1807 |
+
const e = "WebSocket was closed before the connection was established";
|
1808 |
+
b(this, this._req, e);
|
1809 |
+
return;
|
1810 |
+
}
|
1811 |
+
this._socket && (this._readyState = d.CLOSING, this._socket.destroy());
|
1812 |
+
}
|
1813 |
+
}
|
1814 |
+
};
|
1815 |
+
Object.defineProperty(m, "CONNECTING", {
|
1816 |
+
enumerable: !0,
|
1817 |
+
value: O.indexOf("CONNECTING")
|
1818 |
+
});
|
1819 |
+
Object.defineProperty(m.prototype, "CONNECTING", {
|
1820 |
+
enumerable: !0,
|
1821 |
+
value: O.indexOf("CONNECTING")
|
1822 |
+
});
|
1823 |
+
Object.defineProperty(m, "OPEN", {
|
1824 |
+
enumerable: !0,
|
1825 |
+
value: O.indexOf("OPEN")
|
1826 |
+
});
|
1827 |
+
Object.defineProperty(m.prototype, "OPEN", {
|
1828 |
+
enumerable: !0,
|
1829 |
+
value: O.indexOf("OPEN")
|
1830 |
+
});
|
1831 |
+
Object.defineProperty(m, "CLOSING", {
|
1832 |
+
enumerable: !0,
|
1833 |
+
value: O.indexOf("CLOSING")
|
1834 |
+
});
|
1835 |
+
Object.defineProperty(m.prototype, "CLOSING", {
|
1836 |
+
enumerable: !0,
|
1837 |
+
value: O.indexOf("CLOSING")
|
1838 |
+
});
|
1839 |
+
Object.defineProperty(m, "CLOSED", {
|
1840 |
+
enumerable: !0,
|
1841 |
+
value: O.indexOf("CLOSED")
|
1842 |
+
});
|
1843 |
+
Object.defineProperty(m.prototype, "CLOSED", {
|
1844 |
+
enumerable: !0,
|
1845 |
+
value: O.indexOf("CLOSED")
|
1846 |
+
});
|
1847 |
+
[
|
1848 |
+
"binaryType",
|
1849 |
+
"bufferedAmount",
|
1850 |
+
"extensions",
|
1851 |
+
"isPaused",
|
1852 |
+
"protocol",
|
1853 |
+
"readyState",
|
1854 |
+
"url"
|
1855 |
+
].forEach((s) => {
|
1856 |
+
Object.defineProperty(m.prototype, s, { enumerable: !0 });
|
1857 |
+
});
|
1858 |
+
["open", "error", "close", "message"].forEach((s) => {
|
1859 |
+
Object.defineProperty(m.prototype, `on${s}`, {
|
1860 |
+
enumerable: !0,
|
1861 |
+
get() {
|
1862 |
+
for (const e of this.listeners(s))
|
1863 |
+
if (e[ge])
|
1864 |
+
return e[ds];
|
1865 |
+
return null;
|
1866 |
+
},
|
1867 |
+
set(e) {
|
1868 |
+
for (const t of this.listeners(s))
|
1869 |
+
if (t[ge]) {
|
1870 |
+
this.removeListener(s, t);
|
1871 |
+
break;
|
1872 |
+
}
|
1873 |
+
typeof e == "function" && this.addEventListener(s, e, {
|
1874 |
+
[ge]: !0
|
1875 |
+
});
|
1876 |
+
}
|
1877 |
+
});
|
1878 |
+
});
|
1879 |
+
m.prototype.addEventListener = ps;
|
1880 |
+
m.prototype.removeEventListener = ms;
|
1881 |
+
var ft = m;
|
1882 |
+
function ht(s, e, t, r) {
|
1883 |
+
const i = {
|
1884 |
+
protocolVersion: ye[1],
|
1885 |
+
maxPayload: 104857600,
|
1886 |
+
skipUTF8Validation: !1,
|
1887 |
+
perMessageDeflate: !0,
|
1888 |
+
followRedirects: !1,
|
1889 |
+
maxRedirects: 10,
|
1890 |
+
...r,
|
1891 |
+
createConnection: void 0,
|
1892 |
+
socketPath: void 0,
|
1893 |
+
hostname: void 0,
|
1894 |
+
protocol: void 0,
|
1895 |
+
timeout: void 0,
|
1896 |
+
method: "GET",
|
1897 |
+
host: void 0,
|
1898 |
+
path: void 0,
|
1899 |
+
port: void 0
|
1900 |
+
};
|
1901 |
+
if (!ye.includes(i.protocolVersion))
|
1902 |
+
throw new RangeError(
|
1903 |
+
`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${ye.join(", ")})`
|
1904 |
+
);
|
1905 |
+
let n;
|
1906 |
+
if (e instanceof me)
|
1907 |
+
n = e, s._url = e.href;
|
1908 |
+
else {
|
1909 |
+
try {
|
1910 |
+
n = new me(e);
|
1911 |
+
} catch {
|
1912 |
+
throw new SyntaxError(`Invalid URL: ${e}`);
|
1913 |
+
}
|
1914 |
+
s._url = e;
|
1915 |
+
}
|
1916 |
+
const o = n.protocol === "wss:", l = n.protocol === "ws+unix:";
|
1917 |
+
let f;
|
1918 |
+
if (n.protocol !== "ws:" && !o && !l ? f = `The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"` : l && !n.pathname ? f = "The URL's pathname is empty" : n.hash && (f = "The URL contains a fragment identifier"), f) {
|
1919 |
+
const u = new SyntaxError(f);
|
1920 |
+
if (s._redirects === 0)
|
1921 |
+
throw u;
|
1922 |
+
ee(s, u);
|
1923 |
+
return;
|
1924 |
+
}
|
1925 |
+
const a = o ? 443 : 80, c = ls(16).toString("base64"), h = o ? ns.request : os.request, p = /* @__PURE__ */ new Set();
|
1926 |
+
let v;
|
1927 |
+
if (i.createConnection = o ? xs : bs, i.defaultPort = i.defaultPort || a, i.port = n.port || a, i.host = n.hostname.startsWith("[") ? n.hostname.slice(1, -1) : n.hostname, i.headers = {
|
1928 |
+
...i.headers,
|
1929 |
+
"Sec-WebSocket-Version": i.protocolVersion,
|
1930 |
+
"Sec-WebSocket-Key": c,
|
1931 |
+
Connection: "Upgrade",
|
1932 |
+
Upgrade: "websocket"
|
1933 |
+
}, i.path = n.pathname + n.search, i.timeout = i.handshakeTimeout, i.perMessageDeflate && (v = new T(
|
1934 |
+
i.perMessageDeflate !== !0 ? i.perMessageDeflate : {},
|
1935 |
+
!1,
|
1936 |
+
i.maxPayload
|
1937 |
+
), i.headers["Sec-WebSocket-Extensions"] = gs({
|
1938 |
+
[T.extensionName]: v.offer()
|
1939 |
+
})), t.length) {
|
1940 |
+
for (const u of t) {
|
1941 |
+
if (typeof u != "string" || !Es.test(u) || p.has(u))
|
1942 |
+
throw new SyntaxError(
|
1943 |
+
"An invalid or duplicated subprotocol was specified"
|
1944 |
+
);
|
1945 |
+
p.add(u);
|
1946 |
+
}
|
1947 |
+
i.headers["Sec-WebSocket-Protocol"] = t.join(",");
|
1948 |
+
}
|
1949 |
+
if (i.origin && (i.protocolVersion < 13 ? i.headers["Sec-WebSocket-Origin"] = i.origin : i.headers.Origin = i.origin), (n.username || n.password) && (i.auth = `${n.username}:${n.password}`), l) {
|
1950 |
+
const u = i.path.split(":");
|
1951 |
+
i.socketPath = u[0], i.path = u[1];
|
1952 |
+
}
|
1953 |
+
let _;
|
1954 |
+
if (i.followRedirects) {
|
1955 |
+
if (s._redirects === 0) {
|
1956 |
+
s._originalIpc = l, s._originalSecure = o, s._originalHostOrSocketPath = l ? i.socketPath : n.host;
|
1957 |
+
const u = r && r.headers;
|
1958 |
+
if (r = { ...r, headers: {} }, u)
|
1959 |
+
for (const [E, $] of Object.entries(u))
|
1960 |
+
r.headers[E.toLowerCase()] = $;
|
1961 |
+
} else if (s.listenerCount("redirect") === 0) {
|
1962 |
+
const u = l ? s._originalIpc ? i.socketPath === s._originalHostOrSocketPath : !1 : s._originalIpc ? !1 : n.host === s._originalHostOrSocketPath;
|
1963 |
+
(!u || s._originalSecure && !o) && (delete i.headers.authorization, delete i.headers.cookie, u || delete i.headers.host, i.auth = void 0);
|
1964 |
+
}
|
1965 |
+
i.auth && !r.headers.authorization && (r.headers.authorization = "Basic " + Buffer.from(i.auth).toString("base64")), _ = s._req = h(i), s._redirects && s.emit("redirect", s.url, _);
|
1966 |
+
} else
|
1967 |
+
_ = s._req = h(i);
|
1968 |
+
i.timeout && _.on("timeout", () => {
|
1969 |
+
b(s, _, "Opening handshake has timed out");
|
1970 |
+
}), _.on("error", (u) => {
|
1971 |
+
_ === null || _[lt] || (_ = s._req = null, ee(s, u));
|
1972 |
+
}), _.on("response", (u) => {
|
1973 |
+
const E = u.headers.location, $ = u.statusCode;
|
1974 |
+
if (E && i.followRedirects && $ >= 300 && $ < 400) {
|
1975 |
+
if (++s._redirects > i.maxRedirects) {
|
1976 |
+
b(s, _, "Maximum redirects exceeded");
|
1977 |
+
return;
|
1978 |
+
}
|
1979 |
+
_.abort();
|
1980 |
+
let q;
|
1981 |
+
try {
|
1982 |
+
q = new me(E, e);
|
1983 |
+
} catch {
|
1984 |
+
const L = new SyntaxError(`Invalid URL: ${E}`);
|
1985 |
+
ee(s, L);
|
1986 |
+
return;
|
1987 |
+
}
|
1988 |
+
ht(s, q, t, r);
|
1989 |
+
} else
|
1990 |
+
s.emit("unexpected-response", _, u) || b(
|
1991 |
+
s,
|
1992 |
+
_,
|
1993 |
+
`Unexpected server response: ${u.statusCode}`
|
1994 |
+
);
|
1995 |
+
}), _.on("upgrade", (u, E, $) => {
|
1996 |
+
if (s.emit("upgrade", u), s.readyState !== m.CONNECTING)
|
1997 |
+
return;
|
1998 |
+
if (_ = s._req = null, u.headers.upgrade.toLowerCase() !== "websocket") {
|
1999 |
+
b(s, E, "Invalid Upgrade header");
|
2000 |
+
return;
|
2001 |
+
}
|
2002 |
+
const q = fs("sha1").update(c + us).digest("base64");
|
2003 |
+
if (u.headers["sec-websocket-accept"] !== q) {
|
2004 |
+
b(s, E, "Invalid Sec-WebSocket-Accept header");
|
2005 |
+
return;
|
2006 |
+
}
|
2007 |
+
const D = u.headers["sec-websocket-protocol"];
|
2008 |
+
let L;
|
2009 |
+
if (D !== void 0 ? p.size ? p.has(D) || (L = "Server sent an invalid subprotocol") : L = "Server sent a subprotocol but none was requested" : p.size && (L = "Server sent no subprotocol"), L) {
|
2010 |
+
b(s, E, L);
|
2011 |
+
return;
|
2012 |
+
}
|
2013 |
+
D && (s._protocol = D);
|
2014 |
+
const ke = u.headers["sec-websocket-extensions"];
|
2015 |
+
if (ke !== void 0) {
|
2016 |
+
if (!v) {
|
2017 |
+
b(s, E, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
|
2018 |
+
return;
|
2019 |
+
}
|
2020 |
+
let he;
|
2021 |
+
try {
|
2022 |
+
he = ys(ke);
|
2023 |
+
} catch {
|
2024 |
+
b(s, E, "Invalid Sec-WebSocket-Extensions header");
|
2025 |
+
return;
|
2026 |
+
}
|
2027 |
+
const we = Object.keys(he);
|
2028 |
+
if (we.length !== 1 || we[0] !== T.extensionName) {
|
2029 |
+
b(s, E, "Server indicated an extension that was not requested");
|
2030 |
+
return;
|
2031 |
+
}
|
2032 |
+
try {
|
2033 |
+
v.accept(he[T.extensionName]);
|
2034 |
+
} catch {
|
2035 |
+
b(s, E, "Invalid Sec-WebSocket-Extensions header");
|
2036 |
+
return;
|
2037 |
+
}
|
2038 |
+
s._extensions[T.extensionName] = v;
|
2039 |
+
}
|
2040 |
+
s.setSocket(E, $, {
|
2041 |
+
generateMask: i.generateMask,
|
2042 |
+
maxPayload: i.maxPayload,
|
2043 |
+
skipUTF8Validation: i.skipUTF8Validation
|
2044 |
+
});
|
2045 |
+
}), i.finishRequest ? i.finishRequest(_, s) : _.end();
|
2046 |
+
}
|
2047 |
+
function ee(s, e) {
|
2048 |
+
s._readyState = m.CLOSING, s.emit("error", e), s.emitClose();
|
2049 |
+
}
|
2050 |
+
function bs(s) {
|
2051 |
+
return s.path = s.socketPath, ot.connect(s);
|
2052 |
+
}
|
2053 |
+
function xs(s) {
|
2054 |
+
return s.path = void 0, !s.servername && s.servername !== "" && (s.servername = ot.isIP(s.host) ? "" : s.host), as.connect(s);
|
2055 |
+
}
|
2056 |
+
function b(s, e, t) {
|
2057 |
+
s._readyState = m.CLOSING;
|
2058 |
+
const r = new Error(t);
|
2059 |
+
Error.captureStackTrace(r, b), e.setHeader ? (e[lt] = !0, e.abort(), e.socket && !e.socket.destroyed && e.socket.destroy(), process.nextTick(ee, s, r)) : (e.destroy(r), e.once("error", s.emit.bind(s, "error")), e.once("close", s.emitClose.bind(s)));
|
2060 |
+
}
|
2061 |
+
function ve(s, e, t) {
|
2062 |
+
if (e) {
|
2063 |
+
const r = vs(e).length;
|
2064 |
+
s._socket ? s._sender._bufferedBytes += r : s._bufferedAmount += r;
|
2065 |
+
}
|
2066 |
+
if (t) {
|
2067 |
+
const r = new Error(
|
2068 |
+
`WebSocket is not open: readyState ${s.readyState} (${O[s.readyState]})`
|
2069 |
+
);
|
2070 |
+
process.nextTick(t, r);
|
2071 |
+
}
|
2072 |
+
}
|
2073 |
+
function ks(s, e) {
|
2074 |
+
const t = this[y];
|
2075 |
+
t._closeFrameReceived = !0, t._closeMessage = e, t._closeCode = s, t._socket[y] !== void 0 && (t._socket.removeListener("data", fe), process.nextTick(ct, t._socket), s === 1005 ? t.close() : t.close(s, e));
|
2076 |
+
}
|
2077 |
+
function ws() {
|
2078 |
+
const s = this[y];
|
2079 |
+
s.isPaused || s._socket.resume();
|
2080 |
+
}
|
2081 |
+
function Os(s) {
|
2082 |
+
const e = this[y];
|
2083 |
+
e._socket[y] !== void 0 && (e._socket.removeListener("data", fe), process.nextTick(ct, e._socket), e.close(s[_s])), e.emit("error", s);
|
2084 |
+
}
|
2085 |
+
function Ye() {
|
2086 |
+
this[y].emitClose();
|
2087 |
+
}
|
2088 |
+
function Cs(s, e) {
|
2089 |
+
this[y].emit("message", s, e);
|
2090 |
+
}
|
2091 |
+
function Ts(s) {
|
2092 |
+
const e = this[y];
|
2093 |
+
e.pong(s, !e._isServer, at), e.emit("ping", s);
|
2094 |
+
}
|
2095 |
+
function Ls(s) {
|
2096 |
+
this[y].emit("pong", s);
|
2097 |
+
}
|
2098 |
+
function ct(s) {
|
2099 |
+
s.resume();
|
2100 |
+
}
|
2101 |
+
function ut() {
|
2102 |
+
const s = this[y];
|
2103 |
+
this.removeListener("close", ut), this.removeListener("data", fe), this.removeListener("end", dt), s._readyState = m.CLOSING;
|
2104 |
+
let e;
|
2105 |
+
!this._readableState.endEmitted && !s._closeFrameReceived && !s._receiver._writableState.errorEmitted && (e = s._socket.read()) !== null && s._receiver.write(e), s._receiver.end(), this[y] = void 0, clearTimeout(s._closeTimer), s._receiver._writableState.finished || s._receiver._writableState.errorEmitted ? s.emitClose() : (s._receiver.on("error", Ye), s._receiver.on("finish", Ye));
|
2106 |
+
}
|
2107 |
+
function fe(s) {
|
2108 |
+
this[y]._receiver.write(s) || this.pause();
|
2109 |
+
}
|
2110 |
+
function dt() {
|
2111 |
+
const s = this[y];
|
2112 |
+
s._readyState = m.CLOSING, s._receiver.end(), this.end();
|
2113 |
+
}
|
2114 |
+
function _t() {
|
2115 |
+
const s = this[y];
|
2116 |
+
this.removeListener("error", _t), this.on("error", at), s && (s._readyState = m.CLOSING, this.destroy());
|
2117 |
+
}
|
2118 |
+
const Xs = /* @__PURE__ */ z(ft), { tokenChars: Ns } = ae;
|
2119 |
+
function Ps(s) {
|
2120 |
+
const e = /* @__PURE__ */ new Set();
|
2121 |
+
let t = -1, r = -1, i = 0;
|
2122 |
+
for (i; i < s.length; i++) {
|
2123 |
+
const o = s.charCodeAt(i);
|
2124 |
+
if (r === -1 && Ns[o] === 1)
|
2125 |
+
t === -1 && (t = i);
|
2126 |
+
else if (i !== 0 && (o === 32 || o === 9))
|
2127 |
+
r === -1 && t !== -1 && (r = i);
|
2128 |
+
else if (o === 44) {
|
2129 |
+
if (t === -1)
|
2130 |
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
2131 |
+
r === -1 && (r = i);
|
2132 |
+
const l = s.slice(t, r);
|
2133 |
+
if (e.has(l))
|
2134 |
+
throw new SyntaxError(`The "${l}" subprotocol is duplicated`);
|
2135 |
+
e.add(l), t = r = -1;
|
2136 |
+
} else
|
2137 |
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
2138 |
+
}
|
2139 |
+
if (t === -1 || r !== -1)
|
2140 |
+
throw new SyntaxError("Unexpected end of input");
|
2141 |
+
const n = s.slice(t, i);
|
2142 |
+
if (e.has(n))
|
2143 |
+
throw new SyntaxError(`The "${n}" subprotocol is duplicated`);
|
2144 |
+
return e.add(n), e;
|
2145 |
+
}
|
2146 |
+
var Rs = { parse: Ps };
|
2147 |
+
const Us = S, ie = S, { createHash: Bs } = S, qe = nt, N = oe, $s = Rs, Ms = ft, { GUID: Is, kWebSocket: Ds } = U, Ws = /^[+/0-9A-Za-z]{22}==$/, Ke = 0, Xe = 1, pt = 2;
|
2148 |
+
class As extends Us {
|
2149 |
+
/**
|
2150 |
+
* Create a `WebSocketServer` instance.
|
2151 |
+
*
|
2152 |
+
* @param {Object} options Configuration options
|
2153 |
+
* @param {Number} [options.backlog=511] The maximum length of the queue of
|
2154 |
+
* pending connections
|
2155 |
+
* @param {Boolean} [options.clientTracking=true] Specifies whether or not to
|
2156 |
+
* track clients
|
2157 |
+
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
2158 |
+
* @param {String} [options.host] The hostname where to bind the server
|
2159 |
+
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
2160 |
+
* size
|
2161 |
+
* @param {Boolean} [options.noServer=false] Enable no server mode
|
2162 |
+
* @param {String} [options.path] Accept only connections matching this path
|
2163 |
+
* @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
|
2164 |
+
* permessage-deflate
|
2165 |
+
* @param {Number} [options.port] The port where to bind the server
|
2166 |
+
* @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
|
2167 |
+
* server to use
|
2168 |
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
2169 |
+
* not to skip UTF-8 validation for text and close messages
|
2170 |
+
* @param {Function} [options.verifyClient] A hook to reject connections
|
2171 |
+
* @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
|
2172 |
+
* class to use. It must be the `WebSocket` class or class that extends it
|
2173 |
+
* @param {Function} [callback] A listener for the `listening` event
|
2174 |
+
*/
|
2175 |
+
constructor(e, t) {
|
2176 |
+
if (super(), e = {
|
2177 |
+
maxPayload: 100 * 1024 * 1024,
|
2178 |
+
skipUTF8Validation: !1,
|
2179 |
+
perMessageDeflate: !1,
|
2180 |
+
handleProtocols: null,
|
2181 |
+
clientTracking: !0,
|
2182 |
+
verifyClient: null,
|
2183 |
+
noServer: !1,
|
2184 |
+
backlog: null,
|
2185 |
+
// use default (511 as implemented in net.js)
|
2186 |
+
server: null,
|
2187 |
+
host: null,
|
2188 |
+
path: null,
|
2189 |
+
port: null,
|
2190 |
+
WebSocket: Ms,
|
2191 |
+
...e
|
2192 |
+
}, e.port == null && !e.server && !e.noServer || e.port != null && (e.server || e.noServer) || e.server && e.noServer)
|
2193 |
+
throw new TypeError(
|
2194 |
+
'One and only one of the "port", "server", or "noServer" options must be specified'
|
2195 |
+
);
|
2196 |
+
if (e.port != null ? (this._server = ie.createServer((r, i) => {
|
2197 |
+
const n = ie.STATUS_CODES[426];
|
2198 |
+
i.writeHead(426, {
|
2199 |
+
"Content-Length": n.length,
|
2200 |
+
"Content-Type": "text/plain"
|
2201 |
+
}), i.end(n);
|
2202 |
+
}), this._server.listen(
|
2203 |
+
e.port,
|
2204 |
+
e.host,
|
2205 |
+
e.backlog,
|
2206 |
+
t
|
2207 |
+
)) : e.server && (this._server = e.server), this._server) {
|
2208 |
+
const r = this.emit.bind(this, "connection");
|
2209 |
+
this._removeListeners = js(this._server, {
|
2210 |
+
listening: this.emit.bind(this, "listening"),
|
2211 |
+
error: this.emit.bind(this, "error"),
|
2212 |
+
upgrade: (i, n, o) => {
|
2213 |
+
this.handleUpgrade(i, n, o, r);
|
2214 |
+
}
|
2215 |
+
});
|
2216 |
+
}
|
2217 |
+
e.perMessageDeflate === !0 && (e.perMessageDeflate = {}), e.clientTracking && (this.clients = /* @__PURE__ */ new Set(), this._shouldEmitClose = !1), this.options = e, this._state = Ke;
|
2218 |
+
}
|
2219 |
+
/**
|
2220 |
+
* Returns the bound address, the address family name, and port of the server
|
2221 |
+
* as reported by the operating system if listening on an IP socket.
|
2222 |
+
* If the server is listening on a pipe or UNIX domain socket, the name is
|
2223 |
+
* returned as a string.
|
2224 |
+
*
|
2225 |
+
* @return {(Object|String|null)} The address of the server
|
2226 |
+
* @public
|
2227 |
+
*/
|
2228 |
+
address() {
|
2229 |
+
if (this.options.noServer)
|
2230 |
+
throw new Error('The server is operating in "noServer" mode');
|
2231 |
+
return this._server ? this._server.address() : null;
|
2232 |
+
}
|
2233 |
+
/**
|
2234 |
+
* Stop the server from accepting new connections and emit the `'close'` event
|
2235 |
+
* when all existing connections are closed.
|
2236 |
+
*
|
2237 |
+
* @param {Function} [cb] A one-time listener for the `'close'` event
|
2238 |
+
* @public
|
2239 |
+
*/
|
2240 |
+
close(e) {
|
2241 |
+
if (this._state === pt) {
|
2242 |
+
e && this.once("close", () => {
|
2243 |
+
e(new Error("The server is not running"));
|
2244 |
+
}), process.nextTick(G, this);
|
2245 |
+
return;
|
2246 |
+
}
|
2247 |
+
if (e && this.once("close", e), this._state !== Xe)
|
2248 |
+
if (this._state = Xe, this.options.noServer || this.options.server)
|
2249 |
+
this._server && (this._removeListeners(), this._removeListeners = this._server = null), this.clients ? this.clients.size ? this._shouldEmitClose = !0 : process.nextTick(G, this) : process.nextTick(G, this);
|
2250 |
+
else {
|
2251 |
+
const t = this._server;
|
2252 |
+
this._removeListeners(), this._removeListeners = this._server = null, t.close(() => {
|
2253 |
+
G(this);
|
2254 |
+
});
|
2255 |
+
}
|
2256 |
+
}
|
2257 |
+
/**
|
2258 |
+
* See if a given request should be handled by this server instance.
|
2259 |
+
*
|
2260 |
+
* @param {http.IncomingMessage} req Request object to inspect
|
2261 |
+
* @return {Boolean} `true` if the request is valid, else `false`
|
2262 |
+
* @public
|
2263 |
+
*/
|
2264 |
+
shouldHandle(e) {
|
2265 |
+
if (this.options.path) {
|
2266 |
+
const t = e.url.indexOf("?");
|
2267 |
+
if ((t !== -1 ? e.url.slice(0, t) : e.url) !== this.options.path)
|
2268 |
+
return !1;
|
2269 |
+
}
|
2270 |
+
return !0;
|
2271 |
+
}
|
2272 |
+
/**
|
2273 |
+
* Handle a HTTP Upgrade request.
|
2274 |
+
*
|
2275 |
+
* @param {http.IncomingMessage} req The request object
|
2276 |
+
* @param {(net.Socket|tls.Socket)} socket The network socket between the
|
2277 |
+
* server and client
|
2278 |
+
* @param {Buffer} head The first packet of the upgraded stream
|
2279 |
+
* @param {Function} cb Callback
|
2280 |
+
* @public
|
2281 |
+
*/
|
2282 |
+
handleUpgrade(e, t, r, i) {
|
2283 |
+
t.on("error", Ze);
|
2284 |
+
const n = e.headers["sec-websocket-key"], o = +e.headers["sec-websocket-version"];
|
2285 |
+
if (e.method !== "GET") {
|
2286 |
+
R(this, e, t, 405, "Invalid HTTP method");
|
2287 |
+
return;
|
2288 |
+
}
|
2289 |
+
if (e.headers.upgrade.toLowerCase() !== "websocket") {
|
2290 |
+
R(this, e, t, 400, "Invalid Upgrade header");
|
2291 |
+
return;
|
2292 |
+
}
|
2293 |
+
if (!n || !Ws.test(n)) {
|
2294 |
+
R(this, e, t, 400, "Missing or invalid Sec-WebSocket-Key header");
|
2295 |
+
return;
|
2296 |
+
}
|
2297 |
+
if (o !== 8 && o !== 13) {
|
2298 |
+
R(this, e, t, 400, "Missing or invalid Sec-WebSocket-Version header");
|
2299 |
+
return;
|
2300 |
+
}
|
2301 |
+
if (!this.shouldHandle(e)) {
|
2302 |
+
H(t, 400);
|
2303 |
+
return;
|
2304 |
+
}
|
2305 |
+
const l = e.headers["sec-websocket-protocol"];
|
2306 |
+
let f = /* @__PURE__ */ new Set();
|
2307 |
+
if (l !== void 0)
|
2308 |
+
try {
|
2309 |
+
f = $s.parse(l);
|
2310 |
+
} catch {
|
2311 |
+
R(this, e, t, 400, "Invalid Sec-WebSocket-Protocol header");
|
2312 |
+
return;
|
2313 |
+
}
|
2314 |
+
const a = e.headers["sec-websocket-extensions"], c = {};
|
2315 |
+
if (this.options.perMessageDeflate && a !== void 0) {
|
2316 |
+
const h = new N(
|
2317 |
+
this.options.perMessageDeflate,
|
2318 |
+
!0,
|
2319 |
+
this.options.maxPayload
|
2320 |
+
);
|
2321 |
+
try {
|
2322 |
+
const p = qe.parse(a);
|
2323 |
+
p[N.extensionName] && (h.accept(p[N.extensionName]), c[N.extensionName] = h);
|
2324 |
+
} catch {
|
2325 |
+
R(this, e, t, 400, "Invalid or unacceptable Sec-WebSocket-Extensions header");
|
2326 |
+
return;
|
2327 |
+
}
|
2328 |
+
}
|
2329 |
+
if (this.options.verifyClient) {
|
2330 |
+
const h = {
|
2331 |
+
origin: e.headers[`${o === 8 ? "sec-websocket-origin" : "origin"}`],
|
2332 |
+
secure: !!(e.socket.authorized || e.socket.encrypted),
|
2333 |
+
req: e
|
2334 |
+
};
|
2335 |
+
if (this.options.verifyClient.length === 2) {
|
2336 |
+
this.options.verifyClient(h, (p, v, _, u) => {
|
2337 |
+
if (!p)
|
2338 |
+
return H(t, v || 401, _, u);
|
2339 |
+
this.completeUpgrade(
|
2340 |
+
c,
|
2341 |
+
n,
|
2342 |
+
f,
|
2343 |
+
e,
|
2344 |
+
t,
|
2345 |
+
r,
|
2346 |
+
i
|
2347 |
+
);
|
2348 |
+
});
|
2349 |
+
return;
|
2350 |
+
}
|
2351 |
+
if (!this.options.verifyClient(h))
|
2352 |
+
return H(t, 401);
|
2353 |
+
}
|
2354 |
+
this.completeUpgrade(c, n, f, e, t, r, i);
|
2355 |
+
}
|
2356 |
+
/**
|
2357 |
+
* Upgrade the connection to WebSocket.
|
2358 |
+
*
|
2359 |
+
* @param {Object} extensions The accepted extensions
|
2360 |
+
* @param {String} key The value of the `Sec-WebSocket-Key` header
|
2361 |
+
* @param {Set} protocols The subprotocols
|
2362 |
+
* @param {http.IncomingMessage} req The request object
|
2363 |
+
* @param {(net.Socket|tls.Socket)} socket The network socket between the
|
2364 |
+
* server and client
|
2365 |
+
* @param {Buffer} head The first packet of the upgraded stream
|
2366 |
+
* @param {Function} cb Callback
|
2367 |
+
* @throws {Error} If called more than once with the same socket
|
2368 |
+
* @private
|
2369 |
+
*/
|
2370 |
+
completeUpgrade(e, t, r, i, n, o, l) {
|
2371 |
+
if (!n.readable || !n.writable)
|
2372 |
+
return n.destroy();
|
2373 |
+
if (n[Ds])
|
2374 |
+
throw new Error(
|
2375 |
+
"server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration"
|
2376 |
+
);
|
2377 |
+
if (this._state > Ke)
|
2378 |
+
return H(n, 503);
|
2379 |
+
const a = [
|
2380 |
+
"HTTP/1.1 101 Switching Protocols",
|
2381 |
+
"Upgrade: websocket",
|
2382 |
+
"Connection: Upgrade",
|
2383 |
+
`Sec-WebSocket-Accept: ${Bs("sha1").update(t + Is).digest("base64")}`
|
2384 |
+
], c = new this.options.WebSocket(null);
|
2385 |
+
if (r.size) {
|
2386 |
+
const h = this.options.handleProtocols ? this.options.handleProtocols(r, i) : r.values().next().value;
|
2387 |
+
h && (a.push(`Sec-WebSocket-Protocol: ${h}`), c._protocol = h);
|
2388 |
+
}
|
2389 |
+
if (e[N.extensionName]) {
|
2390 |
+
const h = e[N.extensionName].params, p = qe.format({
|
2391 |
+
[N.extensionName]: [h]
|
2392 |
+
});
|
2393 |
+
a.push(`Sec-WebSocket-Extensions: ${p}`), c._extensions = e;
|
2394 |
+
}
|
2395 |
+
this.emit("headers", a, i), n.write(a.concat(`\r
|
2396 |
+
`).join(`\r
|
2397 |
+
`)), n.removeListener("error", Ze), c.setSocket(n, o, {
|
2398 |
+
maxPayload: this.options.maxPayload,
|
2399 |
+
skipUTF8Validation: this.options.skipUTF8Validation
|
2400 |
+
}), this.clients && (this.clients.add(c), c.on("close", () => {
|
2401 |
+
this.clients.delete(c), this._shouldEmitClose && !this.clients.size && process.nextTick(G, this);
|
2402 |
+
})), l(c, i);
|
2403 |
+
}
|
2404 |
+
}
|
2405 |
+
var Fs = As;
|
2406 |
+
function js(s, e) {
|
2407 |
+
for (const t of Object.keys(e))
|
2408 |
+
s.on(t, e[t]);
|
2409 |
+
return function() {
|
2410 |
+
for (const r of Object.keys(e))
|
2411 |
+
s.removeListener(r, e[r]);
|
2412 |
+
};
|
2413 |
+
}
|
2414 |
+
function G(s) {
|
2415 |
+
s._state = pt, s.emit("close");
|
2416 |
+
}
|
2417 |
+
function Ze() {
|
2418 |
+
this.destroy();
|
2419 |
+
}
|
2420 |
+
function H(s, e, t, r) {
|
2421 |
+
t = t || ie.STATUS_CODES[e], r = {
|
2422 |
+
Connection: "close",
|
2423 |
+
"Content-Type": "text/html",
|
2424 |
+
"Content-Length": Buffer.byteLength(t),
|
2425 |
+
...r
|
2426 |
+
}, s.once("finish", s.destroy), s.end(
|
2427 |
+
`HTTP/1.1 ${e} ${ie.STATUS_CODES[e]}\r
|
2428 |
+
` + Object.keys(r).map((i) => `${i}: ${r[i]}`).join(`\r
|
2429 |
+
`) + `\r
|
2430 |
+
\r
|
2431 |
+
` + t
|
2432 |
+
);
|
2433 |
+
}
|
2434 |
+
function R(s, e, t, r, i) {
|
2435 |
+
if (s.listenerCount("wsClientError")) {
|
2436 |
+
const n = new Error(i);
|
2437 |
+
Error.captureStackTrace(n, R), s.emit("wsClientError", n, t, e);
|
2438 |
+
} else
|
2439 |
+
H(t, r, i);
|
2440 |
+
}
|
2441 |
+
const Zs = /* @__PURE__ */ z(Fs);
|
2442 |
+
export {
|
2443 |
+
qs as Receiver,
|
2444 |
+
Ks as Sender,
|
2445 |
+
Xs as WebSocket,
|
2446 |
+
Zs as WebSocketServer,
|
2447 |
+
Vs as createWebSocketStream,
|
2448 |
+
Xs as default
|
2449 |
+
};
|
src/backend/gradio_unifiedaudio/templates/example/index.js
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const {
|
2 |
+
SvelteComponent: f,
|
3 |
+
append: u,
|
4 |
+
attr: d,
|
5 |
+
detach: g,
|
6 |
+
element: o,
|
7 |
+
init: v,
|
8 |
+
insert: r,
|
9 |
+
noop: c,
|
10 |
+
safe_not_equal: y,
|
11 |
+
set_data: m,
|
12 |
+
text: b,
|
13 |
+
toggle_class: i
|
14 |
+
} = window.__gradio__svelte__internal;
|
15 |
+
function w(a) {
|
16 |
+
let e, n;
|
17 |
+
return {
|
18 |
+
c() {
|
19 |
+
e = o("div"), n = b(
|
20 |
+
/*value*/
|
21 |
+
a[0]
|
22 |
+
), d(e, "class", "svelte-1gecy8w"), i(
|
23 |
+
e,
|
24 |
+
"table",
|
25 |
+
/*type*/
|
26 |
+
a[1] === "table"
|
27 |
+
), i(
|
28 |
+
e,
|
29 |
+
"gallery",
|
30 |
+
/*type*/
|
31 |
+
a[1] === "gallery"
|
32 |
+
), i(
|
33 |
+
e,
|
34 |
+
"selected",
|
35 |
+
/*selected*/
|
36 |
+
a[2]
|
37 |
+
);
|
38 |
+
},
|
39 |
+
m(t, l) {
|
40 |
+
r(t, e, l), u(e, n);
|
41 |
+
},
|
42 |
+
p(t, [l]) {
|
43 |
+
l & /*value*/
|
44 |
+
1 && m(
|
45 |
+
n,
|
46 |
+
/*value*/
|
47 |
+
t[0]
|
48 |
+
), l & /*type*/
|
49 |
+
2 && i(
|
50 |
+
e,
|
51 |
+
"table",
|
52 |
+
/*type*/
|
53 |
+
t[1] === "table"
|
54 |
+
), l & /*type*/
|
55 |
+
2 && i(
|
56 |
+
e,
|
57 |
+
"gallery",
|
58 |
+
/*type*/
|
59 |
+
t[1] === "gallery"
|
60 |
+
), l & /*selected*/
|
61 |
+
4 && i(
|
62 |
+
e,
|
63 |
+
"selected",
|
64 |
+
/*selected*/
|
65 |
+
t[2]
|
66 |
+
);
|
67 |
+
},
|
68 |
+
i: c,
|
69 |
+
o: c,
|
70 |
+
d(t) {
|
71 |
+
t && g(e);
|
72 |
+
}
|
73 |
+
};
|
74 |
+
}
|
75 |
+
function h(a, e, n) {
|
76 |
+
let { value: t } = e, { type: l } = e, { selected: _ = !1 } = e;
|
77 |
+
return a.$$set = (s) => {
|
78 |
+
"value" in s && n(0, t = s.value), "type" in s && n(1, l = s.type), "selected" in s && n(2, _ = s.selected);
|
79 |
+
}, [t, l, _];
|
80 |
+
}
|
81 |
+
class E extends f {
|
82 |
+
constructor(e) {
|
83 |
+
super(), v(this, e, h, w, y, { value: 0, type: 1, selected: 2 });
|
84 |
+
}
|
85 |
+
}
|
86 |
+
export {
|
87 |
+
E as default
|
88 |
+
};
|
src/backend/gradio_unifiedaudio/templates/example/style.css
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.gallery.svelte-1gecy8w{padding:var(--size-1) var(--size-2)}
|
src/backend/gradio_unifiedaudio/unifiedaudio.py
ADDED
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""gr.Audio() component."""
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
from pathlib import Path
|
6 |
+
from typing import Any, Callable, Literal, TypedDict
|
7 |
+
|
8 |
+
import numpy as np
|
9 |
+
import requests
|
10 |
+
from gradio_client import utils as client_utils
|
11 |
+
from gradio_client.documentation import document, set_documentation_group
|
12 |
+
import os
|
13 |
+
import tempfile
|
14 |
+
|
15 |
+
from gradio import processing_utils, utils
|
16 |
+
from gradio.components.base import Component, StreamingInput, StreamingOutput
|
17 |
+
from gradio.data_classes import FileData
|
18 |
+
from gradio.events import Events
|
19 |
+
|
20 |
+
set_documentation_group("component")
|
21 |
+
|
22 |
+
|
23 |
+
class WaveformOptions(TypedDict, total=False):
|
24 |
+
waveform_color: str
|
25 |
+
waveform_progress_color: str
|
26 |
+
show_controls: bool
|
27 |
+
skip_length: int
|
28 |
+
|
29 |
+
|
30 |
+
@document()
|
31 |
+
class UnifiedAudio(
|
32 |
+
StreamingInput,
|
33 |
+
StreamingOutput,
|
34 |
+
Component,
|
35 |
+
):
|
36 |
+
"""
|
37 |
+
Creates an audio component that can be used to upload/record audio (as an input) or display audio (as an output).
|
38 |
+
Preprocessing: passes the uploaded audio as a {Tuple(int, numpy.array)} corresponding to (sample rate in Hz, audio data as a 16-bit int array whose values range from -32768 to 32767), or as a {str} filepath, depending on `type`.
|
39 |
+
Postprocessing: expects a {Tuple(int, numpy.array)} corresponding to (sample rate in Hz, audio data as a float or int numpy array) or as a {str} or {pathlib.Path} filepath or URL to an audio file, or bytes for binary content (recommended for streaming). Note: When converting audio data from float format to WAV, the audio is normalized by its peak value to avoid distortion or clipping in the resulting audio.
|
40 |
+
Examples-format: a {str} filepath to a local file that contains audio.
|
41 |
+
Demos: main_note, generate_tone, reverse_audio
|
42 |
+
Guides: real-time-speech-recognition
|
43 |
+
"""
|
44 |
+
|
45 |
+
EVENTS = [
|
46 |
+
Events.stream,
|
47 |
+
Events.change,
|
48 |
+
Events.clear,
|
49 |
+
Events.play,
|
50 |
+
Events.pause,
|
51 |
+
Events.stop,
|
52 |
+
Events.pause,
|
53 |
+
Events.start_recording,
|
54 |
+
Events.pause_recording,
|
55 |
+
Events.stop_recording,
|
56 |
+
Events.upload,
|
57 |
+
]
|
58 |
+
|
59 |
+
data_model = FileData
|
60 |
+
|
61 |
+
def __init__(
|
62 |
+
self,
|
63 |
+
value: str | Path | tuple[int, np.ndarray] | Callable | None = None,
|
64 |
+
*,
|
65 |
+
image: str | None = None,
|
66 |
+
sources: list[Literal["upload", "microphone"]] | None = None,
|
67 |
+
type: Literal["numpy", "filepath"] = "numpy",
|
68 |
+
label: str | None = None,
|
69 |
+
every: float | None = None,
|
70 |
+
show_label: bool | None = None,
|
71 |
+
container: bool = True,
|
72 |
+
scale: int | None = None,
|
73 |
+
min_width: int = 160,
|
74 |
+
interactive: bool | None = None,
|
75 |
+
visible: bool = True,
|
76 |
+
streaming: bool = False,
|
77 |
+
elem_id: str | None = None,
|
78 |
+
elem_classes: list[str] | str | None = None,
|
79 |
+
render: bool = True,
|
80 |
+
format: Literal["wav", "mp3"] = "wav",
|
81 |
+
autoplay: bool = False,
|
82 |
+
show_download_button=True,
|
83 |
+
show_share_button: bool | None = None,
|
84 |
+
min_length: int | None = None,
|
85 |
+
max_length: int | None = None,
|
86 |
+
waveform_options: WaveformOptions | None = None,
|
87 |
+
):
|
88 |
+
"""
|
89 |
+
Parameters:
|
90 |
+
value: A path, URL, or [sample_rate, numpy array] tuple (sample rate in Hz, audio data as a float or int numpy array) for the default value that UnifiedAudio component is going to take. If callable, the function will be called whenever the app loads to set the initial value of the component.
|
91 |
+
image: A path or URL to an image to display above the audio component. If None, no image will be displayed.
|
92 |
+
sources: A list of sources permitted for audio. "upload" creates a box where user can drop an audio file, "microphone" creates a microphone input. The first element in the list will be used as the default source. If None, defaults to ["upload", "microphone"], or ["microphone"] if `streaming` is True.
|
93 |
+
type: The format the audio file is converted to before being passed into the prediction function. "numpy" converts the audio to a tuple consisting of: (int sample rate, numpy.array for the data), "filepath" passes a str path to a temporary file containing the audio.
|
94 |
+
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
|
95 |
+
every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
|
96 |
+
show_label: if True, will display label.
|
97 |
+
container: If True, will place the component in a container - providing some extra padding around the border.
|
98 |
+
scale: relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
|
99 |
+
min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
|
100 |
+
interactive: if True, will allow users to upload and edit a audio file; if False, can only be used to play audio. If not provided, this is inferred based on whether the component is used as an input or output.
|
101 |
+
visible: If False, component will be hidden.
|
102 |
+
streaming: If set to True when used in a `live` interface as an input, will automatically stream webcam feed. When used set as an output, takes audio chunks yield from the backend and combines them into one streaming audio output.
|
103 |
+
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
104 |
+
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
|
105 |
+
render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
|
106 |
+
format: The file format to save audio files. Either 'wav' or 'mp3'. wav files are lossless but will tend to be larger files. mp3 files tend to be smaller. Default is wav. Applies both when this component is used as an input (when `type` is "format") and when this component is used as an output.
|
107 |
+
autoplay: Whether to automatically play the audio when the component is used as an output. Note: browsers will not autoplay audio files if the user has not interacted with the page yet.
|
108 |
+
show_download_button: If True, will show a download button in the corner of the component for saving audio. If False, icon does not appear.
|
109 |
+
show_share_button: If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.
|
110 |
+
min_length: The minimum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no minimum length.
|
111 |
+
max_length: The maximum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no maximum length.
|
112 |
+
waveform_options: A dictionary of options for the waveform display. Options include: waveform_color (str), waveform_progress_color (str), show_controls (bool), skip_length (int). Default is None, which uses the default values for these options.
|
113 |
+
"""
|
114 |
+
valid_sources: list[Literal["upload", "microphone"]] = ["upload", "microphone"]
|
115 |
+
if sources is None:
|
116 |
+
sources = ["microphone"] if streaming else valid_sources
|
117 |
+
elif isinstance(sources, str) and sources in valid_sources:
|
118 |
+
sources = [sources]
|
119 |
+
elif isinstance(sources, list):
|
120 |
+
pass
|
121 |
+
else:
|
122 |
+
raise ValueError(
|
123 |
+
f"`sources` must be a list consisting of elements in {valid_sources}"
|
124 |
+
)
|
125 |
+
|
126 |
+
self.sources = sources
|
127 |
+
valid_types = ["numpy", "filepath"]
|
128 |
+
if type not in valid_types:
|
129 |
+
raise ValueError(
|
130 |
+
f"Invalid value for parameter `type`: {type}. Please choose from one of: {valid_types}"
|
131 |
+
)
|
132 |
+
self.type = type
|
133 |
+
self.streaming = streaming
|
134 |
+
if self.streaming and "microphone" not in self.sources:
|
135 |
+
raise ValueError(
|
136 |
+
"UnifiedAudio streaming only available if sources includes 'microphone'."
|
137 |
+
)
|
138 |
+
self.format = format
|
139 |
+
self.autoplay = autoplay
|
140 |
+
self.show_download_button = show_download_button
|
141 |
+
self.show_share_button = (
|
142 |
+
(utils.get_space() is not None)
|
143 |
+
if show_share_button is None
|
144 |
+
else show_share_button
|
145 |
+
)
|
146 |
+
self.waveform_options = waveform_options
|
147 |
+
self.min_length = min_length
|
148 |
+
self.max_length = max_length
|
149 |
+
self.temp_files: set[str] = set()
|
150 |
+
self.GRADIO_CACHE = str(
|
151 |
+
Path(
|
152 |
+
os.environ.get("GRADIO_TEMP_DIR")
|
153 |
+
or str(Path(tempfile.gettempdir()) / "gradio")
|
154 |
+
).resolve()
|
155 |
+
)
|
156 |
+
super().__init__(
|
157 |
+
label=label,
|
158 |
+
every=every,
|
159 |
+
show_label=show_label,
|
160 |
+
container=container,
|
161 |
+
scale=scale,
|
162 |
+
min_width=min_width,
|
163 |
+
interactive=interactive,
|
164 |
+
visible=visible,
|
165 |
+
elem_id=elem_id,
|
166 |
+
elem_classes=elem_classes,
|
167 |
+
render=render,
|
168 |
+
value=value,
|
169 |
+
)
|
170 |
+
self.image = self.move_resource_to_block_cache(image)
|
171 |
+
|
172 |
+
def example_inputs(self) -> Any:
|
173 |
+
return "https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav"
|
174 |
+
|
175 |
+
def preprocess(
|
176 |
+
self, payload: FileData | None
|
177 |
+
) -> tuple[int, np.ndarray] | str | None:
|
178 |
+
if payload is None:
|
179 |
+
return payload
|
180 |
+
|
181 |
+
assert payload.path
|
182 |
+
# Need a unique name for the file to avoid re-using the same audio file if
|
183 |
+
# a user submits the same audio file twice
|
184 |
+
temp_file_path = Path(payload.path)
|
185 |
+
output_file_name = str(
|
186 |
+
temp_file_path.with_name(f"{temp_file_path.stem}{temp_file_path.suffix}")
|
187 |
+
)
|
188 |
+
|
189 |
+
sample_rate, data = processing_utils.audio_from_file(temp_file_path)
|
190 |
+
|
191 |
+
duration = len(data) / sample_rate
|
192 |
+
if self.min_length is not None and duration < self.min_length:
|
193 |
+
raise ValueError(
|
194 |
+
f"UnifiedAudio is too short, and must be at least {self.min_length} seconds"
|
195 |
+
)
|
196 |
+
if self.max_length is not None and duration > self.max_length:
|
197 |
+
raise ValueError(
|
198 |
+
f"UnifiedAudio is too long, and must be at most {self.max_length} seconds"
|
199 |
+
)
|
200 |
+
|
201 |
+
if self.type == "numpy":
|
202 |
+
return sample_rate, data
|
203 |
+
elif self.type == "filepath":
|
204 |
+
output_file = str(Path(output_file_name).with_suffix(f".{self.format}"))
|
205 |
+
processing_utils.audio_to_file(
|
206 |
+
sample_rate, data, output_file, format=self.format
|
207 |
+
)
|
208 |
+
return output_file
|
209 |
+
else:
|
210 |
+
raise ValueError(
|
211 |
+
"Unknown type: "
|
212 |
+
+ str(self.type)
|
213 |
+
+ ". Please choose from: 'numpy', 'filepath'."
|
214 |
+
)
|
215 |
+
|
216 |
+
def postprocess(
|
217 |
+
self, value: tuple[int, np.ndarray] | str | Path | bytes | None
|
218 |
+
) -> FileData | bytes | None:
|
219 |
+
"""
|
220 |
+
Parameters:
|
221 |
+
value: audio data in either of the following formats: a tuple of (sample_rate, data), or a string filepath or URL to an audio file, or None.
|
222 |
+
Returns:
|
223 |
+
base64 url data
|
224 |
+
"""
|
225 |
+
if value is None:
|
226 |
+
return None
|
227 |
+
if isinstance(value, bytes):
|
228 |
+
if self.streaming:
|
229 |
+
return value
|
230 |
+
file_path = processing_utils.save_bytes_to_cache(
|
231 |
+
value, "audio", cache_dir=self.GRADIO_CACHE
|
232 |
+
)
|
233 |
+
elif isinstance(value, tuple):
|
234 |
+
sample_rate, data = value
|
235 |
+
file_path = processing_utils.save_audio_to_cache(
|
236 |
+
data, sample_rate, format=self.format, cache_dir=self.GRADIO_CACHE
|
237 |
+
)
|
238 |
+
else:
|
239 |
+
if not isinstance(value, (str, Path)):
|
240 |
+
raise ValueError(f"Cannot process {value} as UnifiedAudio")
|
241 |
+
file_path = str(value)
|
242 |
+
return FileData(path=file_path)
|
243 |
+
|
244 |
+
def stream_output(
|
245 |
+
self, value, output_id: str, first_chunk: bool
|
246 |
+
) -> tuple[bytes | None, Any]:
|
247 |
+
output_file = {
|
248 |
+
"path": output_id,
|
249 |
+
"is_stream": True,
|
250 |
+
}
|
251 |
+
if value is None:
|
252 |
+
return None, output_file
|
253 |
+
if isinstance(value, bytes):
|
254 |
+
return value, output_file
|
255 |
+
if client_utils.is_http_url_like(value["path"]):
|
256 |
+
response = requests.get(value["path"])
|
257 |
+
binary_data = response.content
|
258 |
+
else:
|
259 |
+
output_file["orig_name"] = value["orig_name"]
|
260 |
+
file_path = value["path"]
|
261 |
+
is_wav = file_path.endswith(".wav")
|
262 |
+
with open(file_path, "rb") as f:
|
263 |
+
binary_data = f.read()
|
264 |
+
if is_wav:
|
265 |
+
# strip length information from first chunk header, remove headers entirely from subsequent chunks
|
266 |
+
if first_chunk:
|
267 |
+
binary_data = (
|
268 |
+
binary_data[:4] + b"\xFF\xFF\xFF\xFF" + binary_data[8:]
|
269 |
+
)
|
270 |
+
binary_data = (
|
271 |
+
binary_data[:40] + b"\xFF\xFF\xFF\xFF" + binary_data[44:]
|
272 |
+
)
|
273 |
+
else:
|
274 |
+
binary_data = binary_data[44:]
|
275 |
+
return binary_data, output_file
|
276 |
+
|
277 |
+
def as_example(self, input_data: str | None) -> str:
|
278 |
+
return Path(input_data).name if input_data else ""
|
279 |
+
|
280 |
+
def check_streamable(self):
|
281 |
+
if (
|
282 |
+
self.sources is not None
|
283 |
+
and "microphone" not in self.sources
|
284 |
+
and self.streaming
|
285 |
+
):
|
286 |
+
raise ValueError(
|
287 |
+
"UnifiedAudio streaming only available if source includes 'microphone'."
|
288 |
+
)
|
src/backend/gradio_unifiedaudio/unifiedaudio.pyi
ADDED
@@ -0,0 +1,750 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""gr.Audio() component."""
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
from pathlib import Path
|
6 |
+
from typing import Any, Callable, Literal, TypedDict
|
7 |
+
|
8 |
+
import numpy as np
|
9 |
+
import requests
|
10 |
+
from gradio_client import utils as client_utils
|
11 |
+
from gradio_client.documentation import document, set_documentation_group
|
12 |
+
|
13 |
+
from gradio import processing_utils, utils
|
14 |
+
from gradio.components.base import Component, StreamingInput, StreamingOutput
|
15 |
+
from gradio.data_classes import FileData
|
16 |
+
from gradio.events import Events
|
17 |
+
|
18 |
+
set_documentation_group("component")
|
19 |
+
|
20 |
+
|
21 |
+
class WaveformOptions(TypedDict, total=False):
|
22 |
+
waveform_color: str
|
23 |
+
waveform_progress_color: str
|
24 |
+
show_controls: bool
|
25 |
+
skip_length: int
|
26 |
+
|
27 |
+
from gradio.events import Dependency
|
28 |
+
|
29 |
+
@document()
|
30 |
+
class UnifiedAudio(
|
31 |
+
StreamingInput,
|
32 |
+
StreamingOutput,
|
33 |
+
Component,
|
34 |
+
):
|
35 |
+
"""
|
36 |
+
Creates an audio component that can be used to upload/record audio (as an input) or display audio (as an output).
|
37 |
+
Preprocessing: passes the uploaded audio as a {Tuple(int, numpy.array)} corresponding to (sample rate in Hz, audio data as a 16-bit int array whose values range from -32768 to 32767), or as a {str} filepath, depending on `type`.
|
38 |
+
Postprocessing: expects a {Tuple(int, numpy.array)} corresponding to (sample rate in Hz, audio data as a float or int numpy array) or as a {str} or {pathlib.Path} filepath or URL to an audio file, or bytes for binary content (recommended for streaming). Note: When converting audio data from float format to WAV, the audio is normalized by its peak value to avoid distortion or clipping in the resulting audio.
|
39 |
+
Examples-format: a {str} filepath to a local file that contains audio.
|
40 |
+
Demos: main_note, generate_tone, reverse_audio
|
41 |
+
Guides: real-time-speech-recognition
|
42 |
+
"""
|
43 |
+
|
44 |
+
EVENTS = [
|
45 |
+
Events.stream,
|
46 |
+
Events.change,
|
47 |
+
Events.clear,
|
48 |
+
Events.play,
|
49 |
+
Events.pause,
|
50 |
+
Events.stop,
|
51 |
+
Events.pause,
|
52 |
+
Events.start_recording,
|
53 |
+
Events.pause_recording,
|
54 |
+
Events.stop_recording,
|
55 |
+
Events.upload,
|
56 |
+
]
|
57 |
+
|
58 |
+
data_model = FileData
|
59 |
+
|
60 |
+
def __init__(
|
61 |
+
self,
|
62 |
+
value: str | Path | tuple[int, np.ndarray] | Callable | None = None,
|
63 |
+
*,
|
64 |
+
image: str | None = None,
|
65 |
+
sources: list[Literal["upload", "microphone"]] | None = None,
|
66 |
+
type: Literal["numpy", "filepath"] = "numpy",
|
67 |
+
label: str | None = None,
|
68 |
+
every: float | None = None,
|
69 |
+
show_label: bool | None = None,
|
70 |
+
container: bool = True,
|
71 |
+
scale: int | None = None,
|
72 |
+
min_width: int = 160,
|
73 |
+
interactive: bool | None = None,
|
74 |
+
visible: bool = True,
|
75 |
+
streaming: bool = False,
|
76 |
+
elem_id: str | None = None,
|
77 |
+
elem_classes: list[str] | str | None = None,
|
78 |
+
render: bool = True,
|
79 |
+
format: Literal["wav", "mp3"] = "wav",
|
80 |
+
autoplay: bool = False,
|
81 |
+
show_download_button=True,
|
82 |
+
show_share_button: bool | None = None,
|
83 |
+
min_length: int | None = None,
|
84 |
+
max_length: int | None = None,
|
85 |
+
waveform_options: WaveformOptions | None = None,
|
86 |
+
):
|
87 |
+
"""
|
88 |
+
Parameters:
|
89 |
+
value: A path, URL, or [sample_rate, numpy array] tuple (sample rate in Hz, audio data as a float or int numpy array) for the default value that UnifiedAudio component is going to take. If callable, the function will be called whenever the app loads to set the initial value of the component.
|
90 |
+
image: A path or URL to an image to display above the audio component. If None, no image will be displayed.
|
91 |
+
sources: A list of sources permitted for audio. "upload" creates a box where user can drop an audio file, "microphone" creates a microphone input. The first element in the list will be used as the default source. If None, defaults to ["upload", "microphone"], or ["microphone"] if `streaming` is True.
|
92 |
+
type: The format the audio file is converted to before being passed into the prediction function. "numpy" converts the audio to a tuple consisting of: (int sample rate, numpy.array for the data), "filepath" passes a str path to a temporary file containing the audio.
|
93 |
+
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
|
94 |
+
every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
|
95 |
+
show_label: if True, will display label.
|
96 |
+
container: If True, will place the component in a container - providing some extra padding around the border.
|
97 |
+
scale: relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
|
98 |
+
min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
|
99 |
+
interactive: if True, will allow users to upload and edit a audio file; if False, can only be used to play audio. If not provided, this is inferred based on whether the component is used as an input or output.
|
100 |
+
visible: If False, component will be hidden.
|
101 |
+
streaming: If set to True when used in a `live` interface as an input, will automatically stream webcam feed. When used set as an output, takes audio chunks yield from the backend and combines them into one streaming audio output.
|
102 |
+
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
103 |
+
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
|
104 |
+
render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
|
105 |
+
format: The file format to save audio files. Either 'wav' or 'mp3'. wav files are lossless but will tend to be larger files. mp3 files tend to be smaller. Default is wav. Applies both when this component is used as an input (when `type` is "format") and when this component is used as an output.
|
106 |
+
autoplay: Whether to automatically play the audio when the component is used as an output. Note: browsers will not autoplay audio files if the user has not interacted with the page yet.
|
107 |
+
show_download_button: If True, will show a download button in the corner of the component for saving audio. If False, icon does not appear.
|
108 |
+
show_share_button: If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.
|
109 |
+
min_length: The minimum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no minimum length.
|
110 |
+
max_length: The maximum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no maximum length.
|
111 |
+
waveform_options: A dictionary of options for the waveform display. Options include: waveform_color (str), waveform_progress_color (str), show_controls (bool), skip_length (int). Default is None, which uses the default values for these options.
|
112 |
+
"""
|
113 |
+
valid_sources: list[Literal["upload", "microphone"]] = ["upload", "microphone"]
|
114 |
+
if sources is None:
|
115 |
+
sources = ["microphone"] if streaming else valid_sources
|
116 |
+
elif isinstance(sources, str) and sources in valid_sources:
|
117 |
+
sources = [sources]
|
118 |
+
elif isinstance(sources, list):
|
119 |
+
pass
|
120 |
+
else:
|
121 |
+
raise ValueError(
|
122 |
+
f"`sources` must be a list consisting of elements in {valid_sources}"
|
123 |
+
)
|
124 |
+
|
125 |
+
self.sources = sources
|
126 |
+
valid_types = ["numpy", "filepath"]
|
127 |
+
if type not in valid_types:
|
128 |
+
raise ValueError(
|
129 |
+
f"Invalid value for parameter `type`: {type}. Please choose from one of: {valid_types}"
|
130 |
+
)
|
131 |
+
self.type = type
|
132 |
+
self.streaming = streaming
|
133 |
+
if self.streaming and "microphone" not in self.sources:
|
134 |
+
raise ValueError(
|
135 |
+
"UnifiedAudio streaming only available if sources includes 'microphone'."
|
136 |
+
)
|
137 |
+
self.format = format
|
138 |
+
self.autoplay = autoplay
|
139 |
+
self.show_download_button = show_download_button
|
140 |
+
self.show_share_button = (
|
141 |
+
(utils.get_space() is not None)
|
142 |
+
if show_share_button is None
|
143 |
+
else show_share_button
|
144 |
+
)
|
145 |
+
self.waveform_options = waveform_options
|
146 |
+
self.min_length = min_length
|
147 |
+
self.max_length = max_length
|
148 |
+
self.temp_files: set[str] = set()
|
149 |
+
self.GRADIO_CACHE = str(
|
150 |
+
Path(
|
151 |
+
os.environ.get("GRADIO_TEMP_DIR")
|
152 |
+
or str(Path(tempfile.gettempdir()) / "gradio")
|
153 |
+
).resolve()
|
154 |
+
)
|
155 |
+
super().__init__(
|
156 |
+
label=label,
|
157 |
+
every=every,
|
158 |
+
show_label=show_label,
|
159 |
+
container=container,
|
160 |
+
scale=scale,
|
161 |
+
min_width=min_width,
|
162 |
+
interactive=interactive,
|
163 |
+
visible=visible,
|
164 |
+
elem_id=elem_id,
|
165 |
+
elem_classes=elem_classes,
|
166 |
+
render=render,
|
167 |
+
value=value,
|
168 |
+
)
|
169 |
+
self.image = self.move_resource_to_block_cache(image)
|
170 |
+
|
171 |
+
def example_inputs(self) -> Any:
|
172 |
+
return "https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav"
|
173 |
+
|
174 |
+
def preprocess(
|
175 |
+
self, payload: FileData | None
|
176 |
+
) -> tuple[int, np.ndarray] | str | None:
|
177 |
+
if payload is None:
|
178 |
+
return payload
|
179 |
+
|
180 |
+
assert payload.path
|
181 |
+
# Need a unique name for the file to avoid re-using the same audio file if
|
182 |
+
# a user submits the same audio file twice
|
183 |
+
temp_file_path = Path(payload.path)
|
184 |
+
output_file_name = str(
|
185 |
+
temp_file_path.with_name(f"{temp_file_path.stem}{temp_file_path.suffix}")
|
186 |
+
)
|
187 |
+
|
188 |
+
sample_rate, data = processing_utils.audio_from_file(temp_file_path)
|
189 |
+
|
190 |
+
duration = len(data) / sample_rate
|
191 |
+
if self.min_length is not None and duration < self.min_length:
|
192 |
+
raise ValueError(
|
193 |
+
f"UnifiedAudio is too short, and must be at least {self.min_length} seconds"
|
194 |
+
)
|
195 |
+
if self.max_length is not None and duration > self.max_length:
|
196 |
+
raise ValueError(
|
197 |
+
f"UnifiedAudio is too long, and must be at most {self.max_length} seconds"
|
198 |
+
)
|
199 |
+
|
200 |
+
if self.type == "numpy":
|
201 |
+
return sample_rate, data
|
202 |
+
elif self.type == "filepath":
|
203 |
+
output_file = str(Path(output_file_name).with_suffix(f".{self.format}"))
|
204 |
+
processing_utils.audio_to_file(
|
205 |
+
sample_rate, data, output_file, format=self.format
|
206 |
+
)
|
207 |
+
return output_file
|
208 |
+
else:
|
209 |
+
raise ValueError(
|
210 |
+
"Unknown type: "
|
211 |
+
+ str(self.type)
|
212 |
+
+ ". Please choose from: 'numpy', 'filepath'."
|
213 |
+
)
|
214 |
+
|
215 |
+
def postprocess(
|
216 |
+
self, value: tuple[int, np.ndarray] | str | Path | bytes | None
|
217 |
+
) -> FileData | bytes | None:
|
218 |
+
"""
|
219 |
+
Parameters:
|
220 |
+
value: audio data in either of the following formats: a tuple of (sample_rate, data), or a string filepath or URL to an audio file, or None.
|
221 |
+
Returns:
|
222 |
+
base64 url data
|
223 |
+
"""
|
224 |
+
if value is None:
|
225 |
+
return None
|
226 |
+
if isinstance(value, bytes):
|
227 |
+
if self.streaming:
|
228 |
+
return value
|
229 |
+
file_path = processing_utils.save_bytes_to_cache(
|
230 |
+
value, "audio", cache_dir=self.GRADIO_CACHE
|
231 |
+
)
|
232 |
+
elif isinstance(value, tuple):
|
233 |
+
sample_rate, data = value
|
234 |
+
file_path = processing_utils.save_audio_to_cache(
|
235 |
+
data, sample_rate, format=self.format, cache_dir=self.GRADIO_CACHE
|
236 |
+
)
|
237 |
+
else:
|
238 |
+
if not isinstance(value, (str, Path)):
|
239 |
+
raise ValueError(f"Cannot process {value} as UnifiedAudio")
|
240 |
+
file_path = str(value)
|
241 |
+
return FileData(path=file_path)
|
242 |
+
|
243 |
+
def stream_output(
|
244 |
+
self, value, output_id: str, first_chunk: bool
|
245 |
+
) -> tuple[bytes | None, Any]:
|
246 |
+
output_file = {
|
247 |
+
"path": output_id,
|
248 |
+
"is_stream": True,
|
249 |
+
}
|
250 |
+
if value is None:
|
251 |
+
return None, output_file
|
252 |
+
if isinstance(value, bytes):
|
253 |
+
return value, output_file
|
254 |
+
if client_utils.is_http_url_like(value["path"]):
|
255 |
+
response = requests.get(value["path"])
|
256 |
+
binary_data = response.content
|
257 |
+
else:
|
258 |
+
output_file["orig_name"] = value["orig_name"]
|
259 |
+
file_path = value["path"]
|
260 |
+
is_wav = file_path.endswith(".wav")
|
261 |
+
with open(file_path, "rb") as f:
|
262 |
+
binary_data = f.read()
|
263 |
+
if is_wav:
|
264 |
+
# strip length information from first chunk header, remove headers entirely from subsequent chunks
|
265 |
+
if first_chunk:
|
266 |
+
binary_data = (
|
267 |
+
binary_data[:4] + b"\xFF\xFF\xFF\xFF" + binary_data[8:]
|
268 |
+
)
|
269 |
+
binary_data = (
|
270 |
+
binary_data[:40] + b"\xFF\xFF\xFF\xFF" + binary_data[44:]
|
271 |
+
)
|
272 |
+
else:
|
273 |
+
binary_data = binary_data[44:]
|
274 |
+
return binary_data, output_file
|
275 |
+
|
276 |
+
def as_example(self, input_data: str | None) -> str:
|
277 |
+
return Path(input_data).name if input_data else ""
|
278 |
+
|
279 |
+
def check_streamable(self):
|
280 |
+
if (
|
281 |
+
self.sources is not None
|
282 |
+
and "microphone" not in self.sources
|
283 |
+
and self.streaming
|
284 |
+
):
|
285 |
+
raise ValueError(
|
286 |
+
"UnifiedAudio streaming only available if source includes 'microphone'."
|
287 |
+
)
|
288 |
+
|
289 |
+
|
290 |
+
def stream(self,
|
291 |
+
fn: Callable | None,
|
292 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
293 |
+
outputs: Component | Sequence[Component] | None = None,
|
294 |
+
api_name: str | None | Literal[False] = None,
|
295 |
+
scroll_to_output: bool = False,
|
296 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
297 |
+
queue: bool | None = None,
|
298 |
+
batch: bool = False,
|
299 |
+
max_batch_size: int = 4,
|
300 |
+
preprocess: bool = True,
|
301 |
+
postprocess: bool = True,
|
302 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
303 |
+
every: float | None = None,
|
304 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
305 |
+
js: str | None = None,
|
306 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
307 |
+
concurrency_id: str | None = None,
|
308 |
+
show_api: bool = True) -> Dependency:
|
309 |
+
"""
|
310 |
+
Parameters:
|
311 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
312 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
313 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
314 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
315 |
+
scroll_to_output: If True, will scroll to output component on completion
|
316 |
+
show_progress: If True, will show progress animation while pending
|
317 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
318 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
319 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
320 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
321 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
322 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
323 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
324 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
325 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
326 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
327 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
328 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
329 |
+
"""
|
330 |
+
...
|
331 |
+
|
332 |
+
def change(self,
|
333 |
+
fn: Callable | None,
|
334 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
335 |
+
outputs: Component | Sequence[Component] | None = None,
|
336 |
+
api_name: str | None | Literal[False] = None,
|
337 |
+
scroll_to_output: bool = False,
|
338 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
339 |
+
queue: bool | None = None,
|
340 |
+
batch: bool = False,
|
341 |
+
max_batch_size: int = 4,
|
342 |
+
preprocess: bool = True,
|
343 |
+
postprocess: bool = True,
|
344 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
345 |
+
every: float | None = None,
|
346 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
347 |
+
js: str | None = None,
|
348 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
349 |
+
concurrency_id: str | None = None,
|
350 |
+
show_api: bool = True) -> Dependency:
|
351 |
+
"""
|
352 |
+
Parameters:
|
353 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
354 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
355 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
356 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
357 |
+
scroll_to_output: If True, will scroll to output component on completion
|
358 |
+
show_progress: If True, will show progress animation while pending
|
359 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
360 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
361 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
362 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
363 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
364 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
365 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
366 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
367 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
368 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
369 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
370 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
371 |
+
"""
|
372 |
+
...
|
373 |
+
|
374 |
+
def clear(self,
|
375 |
+
fn: Callable | None,
|
376 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
377 |
+
outputs: Component | Sequence[Component] | None = None,
|
378 |
+
api_name: str | None | Literal[False] = None,
|
379 |
+
scroll_to_output: bool = False,
|
380 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
381 |
+
queue: bool | None = None,
|
382 |
+
batch: bool = False,
|
383 |
+
max_batch_size: int = 4,
|
384 |
+
preprocess: bool = True,
|
385 |
+
postprocess: bool = True,
|
386 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
387 |
+
every: float | None = None,
|
388 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
389 |
+
js: str | None = None,
|
390 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
391 |
+
concurrency_id: str | None = None,
|
392 |
+
show_api: bool = True) -> Dependency:
|
393 |
+
"""
|
394 |
+
Parameters:
|
395 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
396 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
397 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
398 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
399 |
+
scroll_to_output: If True, will scroll to output component on completion
|
400 |
+
show_progress: If True, will show progress animation while pending
|
401 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
402 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
403 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
404 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
405 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
406 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
407 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
408 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
409 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
410 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
411 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
412 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
413 |
+
"""
|
414 |
+
...
|
415 |
+
|
416 |
+
def play(self,
|
417 |
+
fn: Callable | None,
|
418 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
419 |
+
outputs: Component | Sequence[Component] | None = None,
|
420 |
+
api_name: str | None | Literal[False] = None,
|
421 |
+
scroll_to_output: bool = False,
|
422 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
423 |
+
queue: bool | None = None,
|
424 |
+
batch: bool = False,
|
425 |
+
max_batch_size: int = 4,
|
426 |
+
preprocess: bool = True,
|
427 |
+
postprocess: bool = True,
|
428 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
429 |
+
every: float | None = None,
|
430 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
431 |
+
js: str | None = None,
|
432 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
433 |
+
concurrency_id: str | None = None,
|
434 |
+
show_api: bool = True) -> Dependency:
|
435 |
+
"""
|
436 |
+
Parameters:
|
437 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
438 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
439 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
440 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
441 |
+
scroll_to_output: If True, will scroll to output component on completion
|
442 |
+
show_progress: If True, will show progress animation while pending
|
443 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
444 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
445 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
446 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
447 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
448 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
449 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
450 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
451 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
452 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
453 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
454 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
455 |
+
"""
|
456 |
+
...
|
457 |
+
|
458 |
+
def pause(self,
|
459 |
+
fn: Callable | None,
|
460 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
461 |
+
outputs: Component | Sequence[Component] | None = None,
|
462 |
+
api_name: str | None | Literal[False] = None,
|
463 |
+
scroll_to_output: bool = False,
|
464 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
465 |
+
queue: bool | None = None,
|
466 |
+
batch: bool = False,
|
467 |
+
max_batch_size: int = 4,
|
468 |
+
preprocess: bool = True,
|
469 |
+
postprocess: bool = True,
|
470 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
471 |
+
every: float | None = None,
|
472 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
473 |
+
js: str | None = None,
|
474 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
475 |
+
concurrency_id: str | None = None,
|
476 |
+
show_api: bool = True) -> Dependency:
|
477 |
+
"""
|
478 |
+
Parameters:
|
479 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
480 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
481 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
482 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
483 |
+
scroll_to_output: If True, will scroll to output component on completion
|
484 |
+
show_progress: If True, will show progress animation while pending
|
485 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
486 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
487 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
488 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
489 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
490 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
491 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
492 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
493 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
494 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
495 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
496 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
497 |
+
"""
|
498 |
+
...
|
499 |
+
|
500 |
+
def stop(self,
|
501 |
+
fn: Callable | None,
|
502 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
503 |
+
outputs: Component | Sequence[Component] | None = None,
|
504 |
+
api_name: str | None | Literal[False] = None,
|
505 |
+
scroll_to_output: bool = False,
|
506 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
507 |
+
queue: bool | None = None,
|
508 |
+
batch: bool = False,
|
509 |
+
max_batch_size: int = 4,
|
510 |
+
preprocess: bool = True,
|
511 |
+
postprocess: bool = True,
|
512 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
513 |
+
every: float | None = None,
|
514 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
515 |
+
js: str | None = None,
|
516 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
517 |
+
concurrency_id: str | None = None,
|
518 |
+
show_api: bool = True) -> Dependency:
|
519 |
+
"""
|
520 |
+
Parameters:
|
521 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
522 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
523 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
524 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
525 |
+
scroll_to_output: If True, will scroll to output component on completion
|
526 |
+
show_progress: If True, will show progress animation while pending
|
527 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
528 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
529 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
530 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
531 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
532 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
533 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
534 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
535 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
536 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
537 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
538 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
539 |
+
"""
|
540 |
+
...
|
541 |
+
|
542 |
+
def pause(self,
|
543 |
+
fn: Callable | None,
|
544 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
545 |
+
outputs: Component | Sequence[Component] | None = None,
|
546 |
+
api_name: str | None | Literal[False] = None,
|
547 |
+
scroll_to_output: bool = False,
|
548 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
549 |
+
queue: bool | None = None,
|
550 |
+
batch: bool = False,
|
551 |
+
max_batch_size: int = 4,
|
552 |
+
preprocess: bool = True,
|
553 |
+
postprocess: bool = True,
|
554 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
555 |
+
every: float | None = None,
|
556 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
557 |
+
js: str | None = None,
|
558 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
559 |
+
concurrency_id: str | None = None,
|
560 |
+
show_api: bool = True) -> Dependency:
|
561 |
+
"""
|
562 |
+
Parameters:
|
563 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
564 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
565 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
566 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
567 |
+
scroll_to_output: If True, will scroll to output component on completion
|
568 |
+
show_progress: If True, will show progress animation while pending
|
569 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
570 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
571 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
572 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
573 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
574 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
575 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
576 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
577 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
578 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
579 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
580 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
581 |
+
"""
|
582 |
+
...
|
583 |
+
|
584 |
+
def start_recording(self,
|
585 |
+
fn: Callable | None,
|
586 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
587 |
+
outputs: Component | Sequence[Component] | None = None,
|
588 |
+
api_name: str | None | Literal[False] = None,
|
589 |
+
scroll_to_output: bool = False,
|
590 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
591 |
+
queue: bool | None = None,
|
592 |
+
batch: bool = False,
|
593 |
+
max_batch_size: int = 4,
|
594 |
+
preprocess: bool = True,
|
595 |
+
postprocess: bool = True,
|
596 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
597 |
+
every: float | None = None,
|
598 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
599 |
+
js: str | None = None,
|
600 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
601 |
+
concurrency_id: str | None = None,
|
602 |
+
show_api: bool = True) -> Dependency:
|
603 |
+
"""
|
604 |
+
Parameters:
|
605 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
606 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
607 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
608 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
609 |
+
scroll_to_output: If True, will scroll to output component on completion
|
610 |
+
show_progress: If True, will show progress animation while pending
|
611 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
612 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
613 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
614 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
615 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
616 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
617 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
618 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
619 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
620 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
621 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
622 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
623 |
+
"""
|
624 |
+
...
|
625 |
+
|
626 |
+
def pause_recording(self,
|
627 |
+
fn: Callable | None,
|
628 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
629 |
+
outputs: Component | Sequence[Component] | None = None,
|
630 |
+
api_name: str | None | Literal[False] = None,
|
631 |
+
scroll_to_output: bool = False,
|
632 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
633 |
+
queue: bool | None = None,
|
634 |
+
batch: bool = False,
|
635 |
+
max_batch_size: int = 4,
|
636 |
+
preprocess: bool = True,
|
637 |
+
postprocess: bool = True,
|
638 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
639 |
+
every: float | None = None,
|
640 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
641 |
+
js: str | None = None,
|
642 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
643 |
+
concurrency_id: str | None = None,
|
644 |
+
show_api: bool = True) -> Dependency:
|
645 |
+
"""
|
646 |
+
Parameters:
|
647 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
648 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
649 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
650 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
651 |
+
scroll_to_output: If True, will scroll to output component on completion
|
652 |
+
show_progress: If True, will show progress animation while pending
|
653 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
654 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
655 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
656 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
657 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
658 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
659 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
660 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
661 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
662 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
663 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
664 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
665 |
+
"""
|
666 |
+
...
|
667 |
+
|
668 |
+
def stop_recording(self,
|
669 |
+
fn: Callable | None,
|
670 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
671 |
+
outputs: Component | Sequence[Component] | None = None,
|
672 |
+
api_name: str | None | Literal[False] = None,
|
673 |
+
scroll_to_output: bool = False,
|
674 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
675 |
+
queue: bool | None = None,
|
676 |
+
batch: bool = False,
|
677 |
+
max_batch_size: int = 4,
|
678 |
+
preprocess: bool = True,
|
679 |
+
postprocess: bool = True,
|
680 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
681 |
+
every: float | None = None,
|
682 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
683 |
+
js: str | None = None,
|
684 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
685 |
+
concurrency_id: str | None = None,
|
686 |
+
show_api: bool = True) -> Dependency:
|
687 |
+
"""
|
688 |
+
Parameters:
|
689 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
690 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
691 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
692 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
693 |
+
scroll_to_output: If True, will scroll to output component on completion
|
694 |
+
show_progress: If True, will show progress animation while pending
|
695 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
696 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
697 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
698 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
699 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
700 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
701 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
702 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
703 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
704 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
705 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
706 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
707 |
+
"""
|
708 |
+
...
|
709 |
+
|
710 |
+
def upload(self,
|
711 |
+
fn: Callable | None,
|
712 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
713 |
+
outputs: Component | Sequence[Component] | None = None,
|
714 |
+
api_name: str | None | Literal[False] = None,
|
715 |
+
scroll_to_output: bool = False,
|
716 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
717 |
+
queue: bool | None = None,
|
718 |
+
batch: bool = False,
|
719 |
+
max_batch_size: int = 4,
|
720 |
+
preprocess: bool = True,
|
721 |
+
postprocess: bool = True,
|
722 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
723 |
+
every: float | None = None,
|
724 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
725 |
+
js: str | None = None,
|
726 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
727 |
+
concurrency_id: str | None = None,
|
728 |
+
show_api: bool = True) -> Dependency:
|
729 |
+
"""
|
730 |
+
Parameters:
|
731 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
732 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
733 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
734 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
735 |
+
scroll_to_output: If True, will scroll to output component on completion
|
736 |
+
show_progress: If True, will show progress animation while pending
|
737 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
738 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
739 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
740 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
741 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
742 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
743 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
744 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
745 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
746 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
747 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
748 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
749 |
+
"""
|
750 |
+
...
|
src/demo/__init__.py
ADDED
File without changes
|
src/demo/app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_unifiedaudio import UnifiedAudio
|
4 |
+
from os.path import abspath, join, pardir
|
5 |
+
from pathlib import Path
|
6 |
+
|
7 |
+
example = UnifiedAudio().example_inputs()
|
8 |
+
dir_ = Path(__file__).parent
|
9 |
+
|
10 |
+
def test_mic(audio):
|
11 |
+
return UnifiedAudio(value=audio)
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
mic = UnifiedAudio(sources="microphone")
|
15 |
+
mic.change(test_mic, mic, mic)
|
16 |
+
|
17 |
+
if __name__ == '__main__':
|
18 |
+
demo.launch()
|
src/demo/bubbly-trim.mp3
ADDED
Binary file (804 kB). View file
|
|
src/demo/css.css
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
html {
|
2 |
+
font-family: Inter;
|
3 |
+
font-size: 16px;
|
4 |
+
font-weight: 400;
|
5 |
+
line-height: 1.5;
|
6 |
+
-webkit-text-size-adjust: 100%;
|
7 |
+
background: #fff;
|
8 |
+
color: #323232;
|
9 |
+
-webkit-font-smoothing: antialiased;
|
10 |
+
-moz-osx-font-smoothing: grayscale;
|
11 |
+
text-rendering: optimizeLegibility;
|
12 |
+
}
|
13 |
+
|
14 |
+
:root {
|
15 |
+
--space: 1;
|
16 |
+
--vspace: calc(var(--space) * 1rem);
|
17 |
+
--vspace-0: calc(3 * var(--space) * 1rem);
|
18 |
+
--vspace-1: calc(2 * var(--space) * 1rem);
|
19 |
+
--vspace-2: calc(1.5 * var(--space) * 1rem);
|
20 |
+
--vspace-3: calc(0.5 * var(--space) * 1rem);
|
21 |
+
}
|
22 |
+
|
23 |
+
.app {
|
24 |
+
max-width: 748px !important;
|
25 |
+
}
|
26 |
+
|
27 |
+
.prose p {
|
28 |
+
margin: var(--vspace) 0;
|
29 |
+
line-height: var(--vspace * 2);
|
30 |
+
font-size: 1rem;
|
31 |
+
}
|
32 |
+
|
33 |
+
code {
|
34 |
+
font-family: "Inconsolata", sans-serif;
|
35 |
+
font-size: 16px;
|
36 |
+
}
|
37 |
+
|
38 |
+
h1,
|
39 |
+
h1 code {
|
40 |
+
font-weight: 400;
|
41 |
+
line-height: calc(2.5 / var(--space) * var(--vspace));
|
42 |
+
}
|
43 |
+
|
44 |
+
h1 code {
|
45 |
+
background: none;
|
46 |
+
border: none;
|
47 |
+
letter-spacing: 0.05em;
|
48 |
+
padding-bottom: 5px;
|
49 |
+
position: relative;
|
50 |
+
padding: 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
h2 {
|
54 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
55 |
+
line-height: 1em;
|
56 |
+
}
|
57 |
+
|
58 |
+
h3,
|
59 |
+
h3 code {
|
60 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
61 |
+
line-height: 1em;
|
62 |
+
}
|
63 |
+
|
64 |
+
h4,
|
65 |
+
h5,
|
66 |
+
h6 {
|
67 |
+
margin: var(--vspace-3) 0 var(--vspace-3) 0;
|
68 |
+
line-height: var(--vspace);
|
69 |
+
}
|
70 |
+
|
71 |
+
.bigtitle,
|
72 |
+
h1,
|
73 |
+
h1 code {
|
74 |
+
font-size: calc(8px * 4.5);
|
75 |
+
word-break: break-word;
|
76 |
+
}
|
77 |
+
|
78 |
+
.title,
|
79 |
+
h2,
|
80 |
+
h2 code {
|
81 |
+
font-size: calc(8px * 3.375);
|
82 |
+
font-weight: lighter;
|
83 |
+
word-break: break-word;
|
84 |
+
border: none;
|
85 |
+
background: none;
|
86 |
+
}
|
87 |
+
|
88 |
+
.subheading1,
|
89 |
+
h3,
|
90 |
+
h3 code {
|
91 |
+
font-size: calc(8px * 1.8);
|
92 |
+
font-weight: 600;
|
93 |
+
border: none;
|
94 |
+
background: none;
|
95 |
+
letter-spacing: 0.1em;
|
96 |
+
text-transform: uppercase;
|
97 |
+
}
|
98 |
+
|
99 |
+
h2 code {
|
100 |
+
padding: 0;
|
101 |
+
position: relative;
|
102 |
+
letter-spacing: 0.05em;
|
103 |
+
}
|
104 |
+
|
105 |
+
blockquote {
|
106 |
+
font-size: calc(8px * 1.1667);
|
107 |
+
font-style: italic;
|
108 |
+
line-height: calc(1.1667 * var(--vspace));
|
109 |
+
margin: var(--vspace-2) var(--vspace-2);
|
110 |
+
}
|
111 |
+
|
112 |
+
.subheading2,
|
113 |
+
h4 {
|
114 |
+
font-size: calc(8px * 1.4292);
|
115 |
+
text-transform: uppercase;
|
116 |
+
font-weight: 600;
|
117 |
+
}
|
118 |
+
|
119 |
+
.subheading3,
|
120 |
+
h5 {
|
121 |
+
font-size: calc(8px * 1.2917);
|
122 |
+
line-height: calc(1.2917 * var(--vspace));
|
123 |
+
|
124 |
+
font-weight: lighter;
|
125 |
+
text-transform: uppercase;
|
126 |
+
letter-spacing: 0.15em;
|
127 |
+
}
|
128 |
+
|
129 |
+
h6 {
|
130 |
+
font-size: calc(8px * 1.1667);
|
131 |
+
font-size: 1.1667em;
|
132 |
+
font-weight: normal;
|
133 |
+
font-style: italic;
|
134 |
+
font-family: "le-monde-livre-classic-byol", serif !important;
|
135 |
+
letter-spacing: 0px !important;
|
136 |
+
}
|
137 |
+
|
138 |
+
#start .md > *:first-child {
|
139 |
+
margin-top: 0;
|
140 |
+
}
|
141 |
+
|
142 |
+
h2 + h3 {
|
143 |
+
margin-top: 0;
|
144 |
+
}
|
145 |
+
|
146 |
+
.md hr {
|
147 |
+
border: none;
|
148 |
+
border-top: 1px solid var(--block-border-color);
|
149 |
+
margin: var(--vspace-2) 0 var(--vspace-2) 0;
|
150 |
+
}
|
151 |
+
.prose ul {
|
152 |
+
margin: var(--vspace-2) 0 var(--vspace-1) 0;
|
153 |
+
}
|
154 |
+
|
155 |
+
.gap {
|
156 |
+
gap: 0;
|
157 |
+
}
|
src/demo/freeman.jpg
ADDED
src/demo/space.py
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from app import demo as app
|
4 |
+
import os
|
5 |
+
|
6 |
+
_docs = {'UnifiedAudio': {'description': 'Creates an audio component that can be used to upload/record audio (as an input) or display audio (as an output).', 'members': {'__init__': {'value': {'type': 'str\n | pathlib.Path\n | tuple[int, numpy.ndarray]\n | Callable\n | None', 'default': 'None', 'description': 'A path, URL, or [sample_rate, numpy array] tuple (sample rate in Hz, audio data as a float or int numpy array) for the default value that UnifiedAudio component is going to take. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'image': {'type': 'str | None', 'default': 'None', 'description': 'A path or URL to an image to display above the audio component. If None, no image will be displayed.'}, 'sources': {'type': 'list["upload" | "microphone"] | None', 'default': 'None', 'description': 'A list of sources permitted for audio. "upload" creates a box where user can drop an audio file, "microphone" creates a microphone input. The first element in the list will be used as the default source. If None, defaults to ["upload", "microphone"], or ["microphone"] if `streaming` is True.'}, 'type': {'type': '"numpy" | "filepath"', 'default': '"numpy"', 'description': 'The format the audio file is converted to before being passed into the prediction function. "numpy" converts the audio to a tuple consisting of: (int sample rate, numpy.array for the data), "filepath" passes a str path to a temporary file containing the audio.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will allow users to upload and edit a audio file; if False, can only be used to play audio. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'streaming': {'type': 'bool', 'default': 'False', 'description': 'If set to True when used in a `live` interface as an input, will automatically stream webcam feed. When used set as an output, takes audio chunks yield from the backend and combines them into one streaming audio output.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'format': {'type': '"wav" | "mp3"', 'default': '"wav"', 'description': 'The file format to save audio files. Either \'wav\' or \'mp3\'. wav files are lossless but will tend to be larger files. mp3 files tend to be smaller. Default is wav. Applies both when this component is used as an input (when `type` is "format") and when this component is used as an output.'}, 'autoplay': {'type': 'bool', 'default': 'False', 'description': 'Whether to automatically play the audio when the component is used as an output. Note: browsers will not autoplay audio files if the user has not interacted with the page yet.'}, 'show_share_button': {'type': 'bool | None', 'default': 'None', 'description': 'If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.'}, 'min_length': {'type': 'int | None', 'default': 'None', 'description': 'The minimum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no minimum length.'}, 'max_length': {'type': 'int | None', 'default': 'None', 'description': 'The maximum length of audio (in seconds) that the user can pass into the prediction function. If None, there is no maximum length.'}, 'waveform_options': {'type': 'WaveformOptions | None', 'default': 'None', 'description': 'A dictionary of options for the waveform display. Options include: waveform_color (str), waveform_progress_color (str), show_controls (bool), skip_length (int). Default is None, which uses the default values for these options.'}}, 'postprocess': {'value': {'type': 'tuple[int, numpy.ndarray]\n | str\n | pathlib.Path\n | bytes\n | None', 'description': 'audio data in either of the following formats: a tuple of (sample_rate, data), or a string filepath or URL to an audio file, or None.'}}, 'preprocess': {'return': {'type': 'tuple[int, numpy.ndarray] | str | None', 'description': None}, 'value': None}}, 'events': {'stream': {'type': None, 'default': None, 'description': 'This listener is triggered when the user streams the UnifiedAudio.'}, 'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the UnifiedAudio changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'clear': {'type': None, 'default': None, 'description': 'This listener is triggered when the user clears the UnifiedAudio using the X button for the component.'}, 'play': {'type': None, 'default': None, 'description': 'This listener is triggered when the user plays the media in the UnifiedAudio.'}, 'pause': {'type': None, 'default': None, 'description': 'This listener is triggered when the media in the UnifiedAudio stops for any reason.'}, 'stop': {'type': None, 'default': None, 'description': 'This listener is triggered when the user reaches the end of the media playing in the UnifiedAudio.'}, 'start_recording': {'type': None, 'default': None, 'description': 'This listener is triggered when the user starts recording with the UnifiedAudio.'}, 'pause_recording': {'type': None, 'default': None, 'description': 'This listener is triggered when the user pauses recording with the UnifiedAudio.'}, 'stop_recording': {'type': None, 'default': None, 'description': 'This listener is triggered when the user stops recording with the UnifiedAudio.'}, 'upload': {'type': None, 'default': None, 'description': 'This listener is triggered when the user uploads a file into the UnifiedAudio.'}}}, '__meta__': {'additional_interfaces': {'WaveformOptions': {'source': 'class WaveformOptions(TypedDict, total=False):\n waveform_color: str\n waveform_progress_color: str\n show_controls: bool\n skip_length: int'}}, 'user_fn_refs': {'UnifiedAudio': []}}}
|
7 |
+
|
8 |
+
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
+
|
10 |
+
with gr.Blocks(
|
11 |
+
css=abs_path,
|
12 |
+
theme=gr.themes.Default(
|
13 |
+
font_mono=[
|
14 |
+
gr.themes.GoogleFont("Inconsolata"),
|
15 |
+
"monospace",
|
16 |
+
],
|
17 |
+
),
|
18 |
+
) as demo:
|
19 |
+
gr.Markdown(
|
20 |
+
"""
|
21 |
+
# `gradio_unifiedaudio`
|
22 |
+
|
23 |
+
<div style="display: flex; gap: 7px;">
|
24 |
+
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.2%20-%20orange">
|
25 |
+
</div>
|
26 |
+
|
27 |
+
Python library for easily interacting with trained machine learning models
|
28 |
+
""", elem_classes=["md-custom"], header_links=True)
|
29 |
+
app.render()
|
30 |
+
gr.Markdown(
|
31 |
+
"""
|
32 |
+
## Installation
|
33 |
+
|
34 |
+
```bash
|
35 |
+
pip install gradio_unifiedaudio
|
36 |
+
```
|
37 |
+
|
38 |
+
## Usage
|
39 |
+
|
40 |
+
```python
|
41 |
+
|
42 |
+
import gradio as gr
|
43 |
+
from gradio_unifiedaudio import UnifiedAudio
|
44 |
+
from os.path import abspath, join, pardir
|
45 |
+
from pathlib import Path
|
46 |
+
|
47 |
+
example = UnifiedAudio().example_inputs()
|
48 |
+
dir_ = Path(__file__).parent
|
49 |
+
|
50 |
+
def test_mic(audio):
|
51 |
+
return UnifiedAudio(value=audio)
|
52 |
+
|
53 |
+
with gr.Blocks() as demo:
|
54 |
+
mic = UnifiedAudio(sources="microphone")
|
55 |
+
mic.change(test_mic, mic, mic)
|
56 |
+
|
57 |
+
if __name__ == '__main__':
|
58 |
+
demo.launch()
|
59 |
+
|
60 |
+
```
|
61 |
+
""", elem_classes=["md-custom"], header_links=True)
|
62 |
+
|
63 |
+
|
64 |
+
gr.Markdown("""
|
65 |
+
## `UnifiedAudio`
|
66 |
+
|
67 |
+
### Initialization
|
68 |
+
""", elem_classes=["md-custom"], header_links=True)
|
69 |
+
|
70 |
+
gr.ParamViewer(value=_docs["UnifiedAudio"]["members"]["__init__"], linkify=['WaveformOptions'])
|
71 |
+
|
72 |
+
|
73 |
+
gr.Markdown("### Events")
|
74 |
+
gr.ParamViewer(value=_docs["UnifiedAudio"]["events"], linkify=['Event'])
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
gr.Markdown("""
|
80 |
+
|
81 |
+
### User function
|
82 |
+
|
83 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
84 |
+
|
85 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
86 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
87 |
+
|
88 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
89 |
+
|
90 |
+
- **As output:** Should return, audio data in either of the following formats: a tuple of (sample_rate, data), or a string filepath or URL to an audio file, or None.
|
91 |
+
|
92 |
+
```python
|
93 |
+
def predict(
|
94 |
+
value: tuple[int, numpy.ndarray] | str | None
|
95 |
+
) -> tuple[int, numpy.ndarray]
|
96 |
+
| str
|
97 |
+
| pathlib.Path
|
98 |
+
| bytes
|
99 |
+
| None:
|
100 |
+
return value
|
101 |
+
```
|
102 |
+
""", elem_classes=["md-custom", "UnifiedAudio-user-fn"], header_links=True)
|
103 |
+
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
code_WaveformOptions = gr.Markdown("""
|
108 |
+
## `WaveformOptions`
|
109 |
+
```python
|
110 |
+
class WaveformOptions(TypedDict, total=False):
|
111 |
+
waveform_color: str
|
112 |
+
waveform_progress_color: str
|
113 |
+
show_controls: bool
|
114 |
+
skip_length: int
|
115 |
+
```""", elem_classes=["md-custom", "WaveformOptions"], header_links=True)
|
116 |
+
|
117 |
+
demo.load(None, js=r"""function() {
|
118 |
+
const refs = {
|
119 |
+
WaveformOptions: [], };
|
120 |
+
const user_fn_refs = {
|
121 |
+
UnifiedAudio: [], };
|
122 |
+
requestAnimationFrame(() => {
|
123 |
+
|
124 |
+
Object.entries(user_fn_refs).forEach(([key, refs]) => {
|
125 |
+
if (refs.length > 0) {
|
126 |
+
const el = document.querySelector(`.${key}-user-fn`);
|
127 |
+
if (!el) return;
|
128 |
+
refs.forEach(ref => {
|
129 |
+
el.innerHTML = el.innerHTML.replace(
|
130 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
131 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
132 |
+
);
|
133 |
+
})
|
134 |
+
}
|
135 |
+
})
|
136 |
+
|
137 |
+
Object.entries(refs).forEach(([key, refs]) => {
|
138 |
+
if (refs.length > 0) {
|
139 |
+
const el = document.querySelector(`.${key}`);
|
140 |
+
if (!el) return;
|
141 |
+
refs.forEach(ref => {
|
142 |
+
el.innerHTML = el.innerHTML.replace(
|
143 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
144 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
145 |
+
);
|
146 |
+
})
|
147 |
+
}
|
148 |
+
})
|
149 |
+
})
|
150 |
+
}
|
151 |
+
|
152 |
+
""")
|
153 |
+
|
154 |
+
demo.launch()
|
src/frontend/Example.svelte
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
export let value: string;
|
3 |
+
export let type: "gallery" | "table";
|
4 |
+
export let selected = false;
|
5 |
+
</script>
|
6 |
+
|
7 |
+
<div
|
8 |
+
class:table={type === "table"}
|
9 |
+
class:gallery={type === "gallery"}
|
10 |
+
class:selected
|
11 |
+
>
|
12 |
+
{value}
|
13 |
+
</div>
|
14 |
+
|
15 |
+
<style>
|
16 |
+
.gallery {
|
17 |
+
padding: var(--size-1) var(--size-2);
|
18 |
+
}
|
19 |
+
</style>
|
src/frontend/Index.svelte
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<svelte:options accessors={true} />
|
2 |
+
|
3 |
+
<script lang="ts">
|
4 |
+
import type { Gradio, ShareData } from "@gradio/utils";
|
5 |
+
|
6 |
+
import type { FileData } from "@gradio/client";
|
7 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
8 |
+
|
9 |
+
import StaticAudio from "./static/StaticAudio.svelte";
|
10 |
+
import InteractiveAudio from "./interactive/InteractiveAudio.svelte";
|
11 |
+
import { StatusTracker } from "@gradio/statustracker";
|
12 |
+
import { Block, UploadText } from "@gradio/atoms";
|
13 |
+
import type { WaveformOptions } from "./shared/types";
|
14 |
+
import { normalise_file } from "@gradio/client";
|
15 |
+
|
16 |
+
export let elem_id = "";
|
17 |
+
export let elem_classes: string[] = [];
|
18 |
+
export let visible = true;
|
19 |
+
export let interactive: boolean;
|
20 |
+
export let value: null | FileData = null;
|
21 |
+
export let sources:
|
22 |
+
| ["microphone"]
|
23 |
+
| ["upload"]
|
24 |
+
| ["microphone", "upload"]
|
25 |
+
| ["upload", "microphone"];
|
26 |
+
export let image: string | FileData | null = null;
|
27 |
+
export let label: string;
|
28 |
+
export let root: string;
|
29 |
+
export let show_label: boolean;
|
30 |
+
export let proxy_url: null | string;
|
31 |
+
export let container = true;
|
32 |
+
export let scale: number | null = null;
|
33 |
+
export let min_width: number | undefined = undefined;
|
34 |
+
export let loading_status: LoadingStatus;
|
35 |
+
export let autoplay = false;
|
36 |
+
export let show_download_button = true;
|
37 |
+
export let show_share_button = false;
|
38 |
+
export let waveform_options: WaveformOptions = {};
|
39 |
+
export let pending: boolean;
|
40 |
+
export let streaming: boolean;
|
41 |
+
export let gradio: Gradio<{
|
42 |
+
change: typeof value;
|
43 |
+
stream: typeof value;
|
44 |
+
error: string;
|
45 |
+
warning: string;
|
46 |
+
edit: never;
|
47 |
+
play: never;
|
48 |
+
pause: never;
|
49 |
+
stop: never;
|
50 |
+
end: never;
|
51 |
+
start_recording: never;
|
52 |
+
pause_recording: never;
|
53 |
+
stop_recording: typeof value;
|
54 |
+
upload: never;
|
55 |
+
clear: never;
|
56 |
+
share: ShareData;
|
57 |
+
}>;
|
58 |
+
|
59 |
+
let old_value: null | FileData | string = null;
|
60 |
+
let _value: null | FileData;
|
61 |
+
$: _value = normalise_file(value, root, proxy_url);
|
62 |
+
|
63 |
+
let active_source: "microphone" | "upload";
|
64 |
+
|
65 |
+
let initial_value: null | FileData = value;
|
66 |
+
|
67 |
+
$: if (value && initial_value === null) {
|
68 |
+
initial_value = value;
|
69 |
+
}
|
70 |
+
|
71 |
+
const handle_reset_value = (): void => {
|
72 |
+
if (initial_value === null || value === initial_value) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
value = initial_value;
|
77 |
+
};
|
78 |
+
|
79 |
+
$: {
|
80 |
+
if (JSON.stringify(value) !== JSON.stringify(old_value)) {
|
81 |
+
old_value = value;
|
82 |
+
gradio.dispatch("change");
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
let dragging: boolean;
|
87 |
+
|
88 |
+
$: if (sources) {
|
89 |
+
active_source = sources[0];
|
90 |
+
}
|
91 |
+
|
92 |
+
const waveform_settings = {
|
93 |
+
height: 50,
|
94 |
+
waveColor: waveform_options.waveform_color || "#9ca3af",
|
95 |
+
progressColor: waveform_options.waveform_progress_color || "#f97316",
|
96 |
+
barWidth: 2,
|
97 |
+
barGap: 3,
|
98 |
+
barHeight: 4,
|
99 |
+
cursorWidth: 2,
|
100 |
+
cursorColor: "#ddd5e9",
|
101 |
+
autoplay: autoplay,
|
102 |
+
barRadius: 10,
|
103 |
+
dragToSeek: true,
|
104 |
+
mediaControls: waveform_options.show_controls
|
105 |
+
};
|
106 |
+
|
107 |
+
function handle_error({ detail }: CustomEvent<string>): void {
|
108 |
+
const [level, status] = detail.includes("Invalid file type")
|
109 |
+
? ["warning", "complete"]
|
110 |
+
: ["error", "error"];
|
111 |
+
loading_status = loading_status || {};
|
112 |
+
loading_status.status = status as LoadingStatus["status"];
|
113 |
+
loading_status.message = detail;
|
114 |
+
gradio.dispatch(level as "error" | "warning", detail);
|
115 |
+
}
|
116 |
+
</script>
|
117 |
+
|
118 |
+
{#if !interactive || value !== null}
|
119 |
+
<StaticAudio
|
120 |
+
i18n={gradio.i18n}
|
121 |
+
{image}
|
122 |
+
{show_label}
|
123 |
+
{show_download_button}
|
124 |
+
{show_share_button}
|
125 |
+
value={_value}
|
126 |
+
{label}
|
127 |
+
{root}
|
128 |
+
{proxy_url}
|
129 |
+
{waveform_settings}
|
130 |
+
on:share={(e) => gradio.dispatch("share", e.detail)}
|
131 |
+
on:error={(e) => gradio.dispatch("error", e.detail)}
|
132 |
+
/>
|
133 |
+
{:else}
|
134 |
+
<InteractiveAudio
|
135 |
+
{label}
|
136 |
+
{show_label}
|
137 |
+
value={_value}
|
138 |
+
on:change={({ detail }) => (value = detail)}
|
139 |
+
on:stream={({ detail }) => {
|
140 |
+
value = detail;
|
141 |
+
gradio.dispatch("stream", value);
|
142 |
+
}}
|
143 |
+
on:drag={({ detail }) => (dragging = detail)}
|
144 |
+
{root}
|
145 |
+
{sources}
|
146 |
+
{active_source}
|
147 |
+
{pending}
|
148 |
+
{streaming}
|
149 |
+
{handle_reset_value}
|
150 |
+
bind:dragging
|
151 |
+
on:edit={() => gradio.dispatch("edit")}
|
152 |
+
on:play={() => gradio.dispatch("play")}
|
153 |
+
on:pause={() => gradio.dispatch("pause")}
|
154 |
+
on:stop={() => gradio.dispatch("stop")}
|
155 |
+
on:end={() => gradio.dispatch("end")}
|
156 |
+
on:start_recording={() => gradio.dispatch("start_recording")}
|
157 |
+
on:pause_recording={() => gradio.dispatch("pause_recording")}
|
158 |
+
on:stop_recording={(e) => gradio.dispatch("stop_recording", e.detail)}
|
159 |
+
on:upload={() => gradio.dispatch("upload")}
|
160 |
+
on:clear={() => gradio.dispatch("clear")}
|
161 |
+
on:error={handle_error}
|
162 |
+
i18n={gradio.i18n}
|
163 |
+
{waveform_settings}
|
164 |
+
>
|
165 |
+
</InteractiveAudio>
|
166 |
+
{/if}
|
src/frontend/index.ts
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { default as Index } from "./Index.svelte";
|
2 |
+
export default Index;
|
3 |
+
export { default as BaseStaticAudio } from "./static/StaticAudio.svelte";
|
4 |
+
export { default as BaseInteractiveAudio } from "./interactive/InteractiveAudio.svelte";
|
5 |
+
export { default as BasePlayer } from "./player/AudioPlayer.svelte";
|
6 |
+
export type { WaveformOptions } from "./shared/types";
|
7 |
+
export { default as BaseExample } from "./Example.svelte";
|
src/frontend/interactive/InteractiveAudio.svelte
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { onMount, onDestroy, createEventDispatcher } from "svelte";
|
3 |
+
import { Upload, ModifyUpload } from "@gradio/upload";
|
4 |
+
import { upload, prepare_files, type FileData } from "@gradio/client";
|
5 |
+
import AudioPlayer from "../player/AudioPlayer.svelte";
|
6 |
+
import { _ } from "svelte-i18n";
|
7 |
+
|
8 |
+
import type { IBlobEvent, IMediaRecorder } from "extendable-media-recorder";
|
9 |
+
import type { I18nFormatter } from "js/app/src/gradio_helper";
|
10 |
+
import AudioRecorder from "../recorder/AudioRecorder.svelte";
|
11 |
+
import StreamAudio from "../streaming/StreamAudio.svelte";
|
12 |
+
import { SelectSource } from "@gradio/atoms";
|
13 |
+
|
14 |
+
export let value: null | FileData = null;
|
15 |
+
export let label: string;
|
16 |
+
export let root: string;
|
17 |
+
export let show_label = true;
|
18 |
+
export let sources:
|
19 |
+
| ["microphone"]
|
20 |
+
| ["upload"]
|
21 |
+
| ["microphone", "upload"]
|
22 |
+
| ["upload", "microphone"] = ["microphone", "upload"];
|
23 |
+
export let pending = false;
|
24 |
+
export let streaming = false;
|
25 |
+
export let i18n: I18nFormatter;
|
26 |
+
export let waveform_settings = {};
|
27 |
+
export let dragging: boolean;
|
28 |
+
export let active_source: "microphone" | "upload";
|
29 |
+
export let handle_reset_value: () => void = () => {};
|
30 |
+
|
31 |
+
$: dispatch("drag", dragging);
|
32 |
+
|
33 |
+
// TODO: make use of this
|
34 |
+
// export let type: "normal" | "numpy" = "normal";
|
35 |
+
let recording = false;
|
36 |
+
let recorder: IMediaRecorder;
|
37 |
+
let mode = "";
|
38 |
+
let header: Uint8Array | undefined = undefined;
|
39 |
+
let pending_stream: Uint8Array[] = [];
|
40 |
+
let submit_pending_stream_on_pending_end = false;
|
41 |
+
let inited = false;
|
42 |
+
|
43 |
+
const STREAM_TIMESLICE = 500;
|
44 |
+
const NUM_HEADER_BYTES = 44;
|
45 |
+
let audio_chunks: Blob[] = [];
|
46 |
+
let module_promises: [
|
47 |
+
Promise<typeof import("extendable-media-recorder")>,
|
48 |
+
Promise<typeof import("extendable-media-recorder-wav-encoder")>
|
49 |
+
];
|
50 |
+
|
51 |
+
function get_modules(): void {
|
52 |
+
module_promises = [
|
53 |
+
import("extendable-media-recorder"),
|
54 |
+
import("extendable-media-recorder-wav-encoder")
|
55 |
+
];
|
56 |
+
}
|
57 |
+
|
58 |
+
if (streaming) {
|
59 |
+
get_modules();
|
60 |
+
}
|
61 |
+
|
62 |
+
const dispatch = createEventDispatcher<{
|
63 |
+
change: FileData | null;
|
64 |
+
stream: FileData;
|
65 |
+
edit: never;
|
66 |
+
play: never;
|
67 |
+
pause: never;
|
68 |
+
stop: never;
|
69 |
+
end: never;
|
70 |
+
drag: boolean;
|
71 |
+
error: string;
|
72 |
+
upload: FileData;
|
73 |
+
clear: undefined;
|
74 |
+
start_recording: undefined;
|
75 |
+
pause_recording: undefined;
|
76 |
+
stop_recording: FileData | null;
|
77 |
+
}>();
|
78 |
+
|
79 |
+
const dispatch_blob = async (
|
80 |
+
blobs: Uint8Array[] | Blob[],
|
81 |
+
event: "stream" | "change" | "stop_recording"
|
82 |
+
): Promise<void> => {
|
83 |
+
let _audio_blob = new File(blobs, "audio.wav");
|
84 |
+
const val = await prepare_files([_audio_blob], event === "stream");
|
85 |
+
value = ((await upload(val, root))?.filter(Boolean) as FileData[])[0];
|
86 |
+
console.log("dispatch blobbbb: ", value);
|
87 |
+
dispatch(event, value);
|
88 |
+
};
|
89 |
+
|
90 |
+
onDestroy(() => {
|
91 |
+
if (streaming && recorder && recorder.state !== "inactive") {
|
92 |
+
recorder.stop();
|
93 |
+
}
|
94 |
+
});
|
95 |
+
|
96 |
+
async function handle_chunk(event: IBlobEvent): Promise<void> {
|
97 |
+
let buffer = await event.data.arrayBuffer();
|
98 |
+
let payload = new Uint8Array(buffer);
|
99 |
+
if (!header) {
|
100 |
+
header = new Uint8Array(buffer.slice(0, NUM_HEADER_BYTES));
|
101 |
+
payload = new Uint8Array(buffer.slice(NUM_HEADER_BYTES));
|
102 |
+
}
|
103 |
+
if (pending) {
|
104 |
+
pending_stream.push(payload);
|
105 |
+
} else {
|
106 |
+
let blobParts = [header].concat(pending_stream, [payload]);
|
107 |
+
dispatch_blob(blobParts, "stream");
|
108 |
+
pending_stream = [];
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
$: if (submit_pending_stream_on_pending_end && pending === false) {
|
113 |
+
submit_pending_stream_on_pending_end = false;
|
114 |
+
if (header && pending_stream) {
|
115 |
+
let blobParts: Uint8Array[] = [header].concat(pending_stream);
|
116 |
+
pending_stream = [];
|
117 |
+
dispatch_blob(blobParts, "stream");
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
function clear(): void {
|
122 |
+
dispatch("change", null);
|
123 |
+
dispatch("clear");
|
124 |
+
mode = "";
|
125 |
+
value = null;
|
126 |
+
}
|
127 |
+
|
128 |
+
function handle_load({ detail }: { detail: FileData }): void {
|
129 |
+
value = detail;
|
130 |
+
dispatch("change", detail);
|
131 |
+
dispatch("upload", detail);
|
132 |
+
}
|
133 |
+
</script>
|
134 |
+
|
135 |
+
<AudioRecorder
|
136 |
+
bind:mode
|
137 |
+
{i18n}
|
138 |
+
{dispatch}
|
139 |
+
{dispatch_blob}
|
140 |
+
{waveform_settings}
|
141 |
+
{handle_reset_value}
|
142 |
+
/>
|
src/frontend/package-lock.json
ADDED
@@ -0,0 +1,1306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "gradio_unifiedaudio",
|
3 |
+
"version": "0.4.3",
|
4 |
+
"lockfileVersion": 3,
|
5 |
+
"requires": true,
|
6 |
+
"packages": {
|
7 |
+
"": {
|
8 |
+
"name": "gradio_unifiedaudio",
|
9 |
+
"version": "0.4.3",
|
10 |
+
"license": "ISC",
|
11 |
+
"dependencies": {
|
12 |
+
"@gradio/atoms": "0.2.1",
|
13 |
+
"@gradio/button": "0.2.3",
|
14 |
+
"@gradio/client": "0.7.2",
|
15 |
+
"@gradio/icons": "0.2.0",
|
16 |
+
"@gradio/statustracker": "0.3.1",
|
17 |
+
"@gradio/upload": "0.3.3",
|
18 |
+
"@gradio/utils": "0.2.0",
|
19 |
+
"@gradio/wasm": "0.2.0",
|
20 |
+
"@types/wavesurfer.js": "^6.0.10",
|
21 |
+
"extendable-media-recorder": "^9.0.0",
|
22 |
+
"extendable-media-recorder-wav-encoder": "^7.0.76",
|
23 |
+
"resize-observer-polyfill": "^1.5.1",
|
24 |
+
"svelte-range-slider-pips": "^2.0.1",
|
25 |
+
"wavesurfer.js": "^7.4.2"
|
26 |
+
}
|
27 |
+
},
|
28 |
+
"node_modules/@ampproject/remapping": {
|
29 |
+
"version": "2.2.1",
|
30 |
+
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz",
|
31 |
+
"integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==",
|
32 |
+
"peer": true,
|
33 |
+
"dependencies": {
|
34 |
+
"@jridgewell/gen-mapping": "^0.3.0",
|
35 |
+
"@jridgewell/trace-mapping": "^0.3.9"
|
36 |
+
},
|
37 |
+
"engines": {
|
38 |
+
"node": ">=6.0.0"
|
39 |
+
}
|
40 |
+
},
|
41 |
+
"node_modules/@babel/runtime": {
|
42 |
+
"version": "7.23.8",
|
43 |
+
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.8.tgz",
|
44 |
+
"integrity": "sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==",
|
45 |
+
"dependencies": {
|
46 |
+
"regenerator-runtime": "^0.14.0"
|
47 |
+
},
|
48 |
+
"engines": {
|
49 |
+
"node": ">=6.9.0"
|
50 |
+
}
|
51 |
+
},
|
52 |
+
"node_modules/@esbuild/aix-ppc64": {
|
53 |
+
"version": "0.19.11",
|
54 |
+
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.11.tgz",
|
55 |
+
"integrity": "sha512-FnzU0LyE3ySQk7UntJO4+qIiQgI7KoODnZg5xzXIrFJlKd2P2gwHsHY4927xj9y5PJmJSzULiUCWmv7iWnNa7g==",
|
56 |
+
"cpu": [
|
57 |
+
"ppc64"
|
58 |
+
],
|
59 |
+
"optional": true,
|
60 |
+
"os": [
|
61 |
+
"aix"
|
62 |
+
],
|
63 |
+
"engines": {
|
64 |
+
"node": ">=12"
|
65 |
+
}
|
66 |
+
},
|
67 |
+
"node_modules/@esbuild/android-arm": {
|
68 |
+
"version": "0.19.11",
|
69 |
+
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.11.tgz",
|
70 |
+
"integrity": "sha512-5OVapq0ClabvKvQ58Bws8+wkLCV+Rxg7tUVbo9xu034Nm536QTII4YzhaFriQ7rMrorfnFKUsArD2lqKbFY4vw==",
|
71 |
+
"cpu": [
|
72 |
+
"arm"
|
73 |
+
],
|
74 |
+
"optional": true,
|
75 |
+
"os": [
|
76 |
+
"android"
|
77 |
+
],
|
78 |
+
"engines": {
|
79 |
+
"node": ">=12"
|
80 |
+
}
|
81 |
+
},
|
82 |
+
"node_modules/@esbuild/android-arm64": {
|
83 |
+
"version": "0.19.11",
|
84 |
+
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.11.tgz",
|
85 |
+
"integrity": "sha512-aiu7K/5JnLj//KOnOfEZ0D90obUkRzDMyqd/wNAUQ34m4YUPVhRZpnqKV9uqDGxT7cToSDnIHsGooyIczu9T+Q==",
|
86 |
+
"cpu": [
|
87 |
+
"arm64"
|
88 |
+
],
|
89 |
+
"optional": true,
|
90 |
+
"os": [
|
91 |
+
"android"
|
92 |
+
],
|
93 |
+
"engines": {
|
94 |
+
"node": ">=12"
|
95 |
+
}
|
96 |
+
},
|
97 |
+
"node_modules/@esbuild/android-x64": {
|
98 |
+
"version": "0.19.11",
|
99 |
+
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.11.tgz",
|
100 |
+
"integrity": "sha512-eccxjlfGw43WYoY9QgB82SgGgDbibcqyDTlk3l3C0jOVHKxrjdc9CTwDUQd0vkvYg5um0OH+GpxYvp39r+IPOg==",
|
101 |
+
"cpu": [
|
102 |
+
"x64"
|
103 |
+
],
|
104 |
+
"optional": true,
|
105 |
+
"os": [
|
106 |
+
"android"
|
107 |
+
],
|
108 |
+
"engines": {
|
109 |
+
"node": ">=12"
|
110 |
+
}
|
111 |
+
},
|
112 |
+
"node_modules/@esbuild/darwin-arm64": {
|
113 |
+
"version": "0.19.11",
|
114 |
+
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.11.tgz",
|
115 |
+
"integrity": "sha512-ETp87DRWuSt9KdDVkqSoKoLFHYTrkyz2+65fj9nfXsaV3bMhTCjtQfw3y+um88vGRKRiF7erPrh/ZuIdLUIVxQ==",
|
116 |
+
"cpu": [
|
117 |
+
"arm64"
|
118 |
+
],
|
119 |
+
"optional": true,
|
120 |
+
"os": [
|
121 |
+
"darwin"
|
122 |
+
],
|
123 |
+
"engines": {
|
124 |
+
"node": ">=12"
|
125 |
+
}
|
126 |
+
},
|
127 |
+
"node_modules/@esbuild/darwin-x64": {
|
128 |
+
"version": "0.19.11",
|
129 |
+
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.11.tgz",
|
130 |
+
"integrity": "sha512-fkFUiS6IUK9WYUO/+22omwetaSNl5/A8giXvQlcinLIjVkxwTLSktbF5f/kJMftM2MJp9+fXqZ5ezS7+SALp4g==",
|
131 |
+
"cpu": [
|
132 |
+
"x64"
|
133 |
+
],
|
134 |
+
"optional": true,
|
135 |
+
"os": [
|
136 |
+
"darwin"
|
137 |
+
],
|
138 |
+
"engines": {
|
139 |
+
"node": ">=12"
|
140 |
+
}
|
141 |
+
},
|
142 |
+
"node_modules/@esbuild/freebsd-arm64": {
|
143 |
+
"version": "0.19.11",
|
144 |
+
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.11.tgz",
|
145 |
+
"integrity": "sha512-lhoSp5K6bxKRNdXUtHoNc5HhbXVCS8V0iZmDvyWvYq9S5WSfTIHU2UGjcGt7UeS6iEYp9eeymIl5mJBn0yiuxA==",
|
146 |
+
"cpu": [
|
147 |
+
"arm64"
|
148 |
+
],
|
149 |
+
"optional": true,
|
150 |
+
"os": [
|
151 |
+
"freebsd"
|
152 |
+
],
|
153 |
+
"engines": {
|
154 |
+
"node": ">=12"
|
155 |
+
}
|
156 |
+
},
|
157 |
+
"node_modules/@esbuild/freebsd-x64": {
|
158 |
+
"version": "0.19.11",
|
159 |
+
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.11.tgz",
|
160 |
+
"integrity": "sha512-JkUqn44AffGXitVI6/AbQdoYAq0TEullFdqcMY/PCUZ36xJ9ZJRtQabzMA+Vi7r78+25ZIBosLTOKnUXBSi1Kw==",
|
161 |
+
"cpu": [
|
162 |
+
"x64"
|
163 |
+
],
|
164 |
+
"optional": true,
|
165 |
+
"os": [
|
166 |
+
"freebsd"
|
167 |
+
],
|
168 |
+
"engines": {
|
169 |
+
"node": ">=12"
|
170 |
+
}
|
171 |
+
},
|
172 |
+
"node_modules/@esbuild/linux-arm": {
|
173 |
+
"version": "0.19.11",
|
174 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.11.tgz",
|
175 |
+
"integrity": "sha512-3CRkr9+vCV2XJbjwgzjPtO8T0SZUmRZla+UL1jw+XqHZPkPgZiyWvbDvl9rqAN8Zl7qJF0O/9ycMtjU67HN9/Q==",
|
176 |
+
"cpu": [
|
177 |
+
"arm"
|
178 |
+
],
|
179 |
+
"optional": true,
|
180 |
+
"os": [
|
181 |
+
"linux"
|
182 |
+
],
|
183 |
+
"engines": {
|
184 |
+
"node": ">=12"
|
185 |
+
}
|
186 |
+
},
|
187 |
+
"node_modules/@esbuild/linux-arm64": {
|
188 |
+
"version": "0.19.11",
|
189 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.11.tgz",
|
190 |
+
"integrity": "sha512-LneLg3ypEeveBSMuoa0kwMpCGmpu8XQUh+mL8XXwoYZ6Be2qBnVtcDI5azSvh7vioMDhoJFZzp9GWp9IWpYoUg==",
|
191 |
+
"cpu": [
|
192 |
+
"arm64"
|
193 |
+
],
|
194 |
+
"optional": true,
|
195 |
+
"os": [
|
196 |
+
"linux"
|
197 |
+
],
|
198 |
+
"engines": {
|
199 |
+
"node": ">=12"
|
200 |
+
}
|
201 |
+
},
|
202 |
+
"node_modules/@esbuild/linux-ia32": {
|
203 |
+
"version": "0.19.11",
|
204 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.11.tgz",
|
205 |
+
"integrity": "sha512-caHy++CsD8Bgq2V5CodbJjFPEiDPq8JJmBdeyZ8GWVQMjRD0sU548nNdwPNvKjVpamYYVL40AORekgfIubwHoA==",
|
206 |
+
"cpu": [
|
207 |
+
"ia32"
|
208 |
+
],
|
209 |
+
"optional": true,
|
210 |
+
"os": [
|
211 |
+
"linux"
|
212 |
+
],
|
213 |
+
"engines": {
|
214 |
+
"node": ">=12"
|
215 |
+
}
|
216 |
+
},
|
217 |
+
"node_modules/@esbuild/linux-loong64": {
|
218 |
+
"version": "0.19.11",
|
219 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.11.tgz",
|
220 |
+
"integrity": "sha512-ppZSSLVpPrwHccvC6nQVZaSHlFsvCQyjnvirnVjbKSHuE5N24Yl8F3UwYUUR1UEPaFObGD2tSvVKbvR+uT1Nrg==",
|
221 |
+
"cpu": [
|
222 |
+
"loong64"
|
223 |
+
],
|
224 |
+
"optional": true,
|
225 |
+
"os": [
|
226 |
+
"linux"
|
227 |
+
],
|
228 |
+
"engines": {
|
229 |
+
"node": ">=12"
|
230 |
+
}
|
231 |
+
},
|
232 |
+
"node_modules/@esbuild/linux-mips64el": {
|
233 |
+
"version": "0.19.11",
|
234 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.11.tgz",
|
235 |
+
"integrity": "sha512-B5x9j0OgjG+v1dF2DkH34lr+7Gmv0kzX6/V0afF41FkPMMqaQ77pH7CrhWeR22aEeHKaeZVtZ6yFwlxOKPVFyg==",
|
236 |
+
"cpu": [
|
237 |
+
"mips64el"
|
238 |
+
],
|
239 |
+
"optional": true,
|
240 |
+
"os": [
|
241 |
+
"linux"
|
242 |
+
],
|
243 |
+
"engines": {
|
244 |
+
"node": ">=12"
|
245 |
+
}
|
246 |
+
},
|
247 |
+
"node_modules/@esbuild/linux-ppc64": {
|
248 |
+
"version": "0.19.11",
|
249 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.11.tgz",
|
250 |
+
"integrity": "sha512-MHrZYLeCG8vXblMetWyttkdVRjQlQUb/oMgBNurVEnhj4YWOr4G5lmBfZjHYQHHN0g6yDmCAQRR8MUHldvvRDA==",
|
251 |
+
"cpu": [
|
252 |
+
"ppc64"
|
253 |
+
],
|
254 |
+
"optional": true,
|
255 |
+
"os": [
|
256 |
+
"linux"
|
257 |
+
],
|
258 |
+
"engines": {
|
259 |
+
"node": ">=12"
|
260 |
+
}
|
261 |
+
},
|
262 |
+
"node_modules/@esbuild/linux-riscv64": {
|
263 |
+
"version": "0.19.11",
|
264 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.11.tgz",
|
265 |
+
"integrity": "sha512-f3DY++t94uVg141dozDu4CCUkYW+09rWtaWfnb3bqe4w5NqmZd6nPVBm+qbz7WaHZCoqXqHz5p6CM6qv3qnSSQ==",
|
266 |
+
"cpu": [
|
267 |
+
"riscv64"
|
268 |
+
],
|
269 |
+
"optional": true,
|
270 |
+
"os": [
|
271 |
+
"linux"
|
272 |
+
],
|
273 |
+
"engines": {
|
274 |
+
"node": ">=12"
|
275 |
+
}
|
276 |
+
},
|
277 |
+
"node_modules/@esbuild/linux-s390x": {
|
278 |
+
"version": "0.19.11",
|
279 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.11.tgz",
|
280 |
+
"integrity": "sha512-A5xdUoyWJHMMlcSMcPGVLzYzpcY8QP1RtYzX5/bS4dvjBGVxdhuiYyFwp7z74ocV7WDc0n1harxmpq2ePOjI0Q==",
|
281 |
+
"cpu": [
|
282 |
+
"s390x"
|
283 |
+
],
|
284 |
+
"optional": true,
|
285 |
+
"os": [
|
286 |
+
"linux"
|
287 |
+
],
|
288 |
+
"engines": {
|
289 |
+
"node": ">=12"
|
290 |
+
}
|
291 |
+
},
|
292 |
+
"node_modules/@esbuild/linux-x64": {
|
293 |
+
"version": "0.19.11",
|
294 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.11.tgz",
|
295 |
+
"integrity": "sha512-grbyMlVCvJSfxFQUndw5mCtWs5LO1gUlwP4CDi4iJBbVpZcqLVT29FxgGuBJGSzyOxotFG4LoO5X+M1350zmPA==",
|
296 |
+
"cpu": [
|
297 |
+
"x64"
|
298 |
+
],
|
299 |
+
"optional": true,
|
300 |
+
"os": [
|
301 |
+
"linux"
|
302 |
+
],
|
303 |
+
"engines": {
|
304 |
+
"node": ">=12"
|
305 |
+
}
|
306 |
+
},
|
307 |
+
"node_modules/@esbuild/netbsd-x64": {
|
308 |
+
"version": "0.19.11",
|
309 |
+
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.11.tgz",
|
310 |
+
"integrity": "sha512-13jvrQZJc3P230OhU8xgwUnDeuC/9egsjTkXN49b3GcS5BKvJqZn86aGM8W9pd14Kd+u7HuFBMVtrNGhh6fHEQ==",
|
311 |
+
"cpu": [
|
312 |
+
"x64"
|
313 |
+
],
|
314 |
+
"optional": true,
|
315 |
+
"os": [
|
316 |
+
"netbsd"
|
317 |
+
],
|
318 |
+
"engines": {
|
319 |
+
"node": ">=12"
|
320 |
+
}
|
321 |
+
},
|
322 |
+
"node_modules/@esbuild/openbsd-x64": {
|
323 |
+
"version": "0.19.11",
|
324 |
+
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.11.tgz",
|
325 |
+
"integrity": "sha512-ysyOGZuTp6SNKPE11INDUeFVVQFrhcNDVUgSQVDzqsqX38DjhPEPATpid04LCoUr2WXhQTEZ8ct/EgJCUDpyNw==",
|
326 |
+
"cpu": [
|
327 |
+
"x64"
|
328 |
+
],
|
329 |
+
"optional": true,
|
330 |
+
"os": [
|
331 |
+
"openbsd"
|
332 |
+
],
|
333 |
+
"engines": {
|
334 |
+
"node": ">=12"
|
335 |
+
}
|
336 |
+
},
|
337 |
+
"node_modules/@esbuild/sunos-x64": {
|
338 |
+
"version": "0.19.11",
|
339 |
+
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.11.tgz",
|
340 |
+
"integrity": "sha512-Hf+Sad9nVwvtxy4DXCZQqLpgmRTQqyFyhT3bZ4F2XlJCjxGmRFF0Shwn9rzhOYRB61w9VMXUkxlBy56dk9JJiQ==",
|
341 |
+
"cpu": [
|
342 |
+
"x64"
|
343 |
+
],
|
344 |
+
"optional": true,
|
345 |
+
"os": [
|
346 |
+
"sunos"
|
347 |
+
],
|
348 |
+
"engines": {
|
349 |
+
"node": ">=12"
|
350 |
+
}
|
351 |
+
},
|
352 |
+
"node_modules/@esbuild/win32-arm64": {
|
353 |
+
"version": "0.19.11",
|
354 |
+
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.11.tgz",
|
355 |
+
"integrity": "sha512-0P58Sbi0LctOMOQbpEOvOL44Ne0sqbS0XWHMvvrg6NE5jQ1xguCSSw9jQeUk2lfrXYsKDdOe6K+oZiwKPilYPQ==",
|
356 |
+
"cpu": [
|
357 |
+
"arm64"
|
358 |
+
],
|
359 |
+
"optional": true,
|
360 |
+
"os": [
|
361 |
+
"win32"
|
362 |
+
],
|
363 |
+
"engines": {
|
364 |
+
"node": ">=12"
|
365 |
+
}
|
366 |
+
},
|
367 |
+
"node_modules/@esbuild/win32-ia32": {
|
368 |
+
"version": "0.19.11",
|
369 |
+
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.11.tgz",
|
370 |
+
"integrity": "sha512-6YOrWS+sDJDmshdBIQU+Uoyh7pQKrdykdefC1avn76ss5c+RN6gut3LZA4E2cH5xUEp5/cA0+YxRaVtRAb0xBg==",
|
371 |
+
"cpu": [
|
372 |
+
"ia32"
|
373 |
+
],
|
374 |
+
"optional": true,
|
375 |
+
"os": [
|
376 |
+
"win32"
|
377 |
+
],
|
378 |
+
"engines": {
|
379 |
+
"node": ">=12"
|
380 |
+
}
|
381 |
+
},
|
382 |
+
"node_modules/@esbuild/win32-x64": {
|
383 |
+
"version": "0.19.11",
|
384 |
+
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.11.tgz",
|
385 |
+
"integrity": "sha512-vfkhltrjCAb603XaFhqhAF4LGDi2M4OrCRrFusyQ+iTLQ/o60QQXxc9cZC/FFpihBI9N1Grn6SMKVJ4KP7Fuiw==",
|
386 |
+
"cpu": [
|
387 |
+
"x64"
|
388 |
+
],
|
389 |
+
"optional": true,
|
390 |
+
"os": [
|
391 |
+
"win32"
|
392 |
+
],
|
393 |
+
"engines": {
|
394 |
+
"node": ">=12"
|
395 |
+
}
|
396 |
+
},
|
397 |
+
"node_modules/@formatjs/ecma402-abstract": {
|
398 |
+
"version": "1.11.4",
|
399 |
+
"resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.4.tgz",
|
400 |
+
"integrity": "sha512-EBikYFp2JCdIfGEb5G9dyCkTGDmC57KSHhRQOC3aYxoPWVZvfWCDjZwkGYHN7Lis/fmuWl906bnNTJifDQ3sXw==",
|
401 |
+
"dependencies": {
|
402 |
+
"@formatjs/intl-localematcher": "0.2.25",
|
403 |
+
"tslib": "^2.1.0"
|
404 |
+
}
|
405 |
+
},
|
406 |
+
"node_modules/@formatjs/fast-memoize": {
|
407 |
+
"version": "1.2.1",
|
408 |
+
"resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-1.2.1.tgz",
|
409 |
+
"integrity": "sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg==",
|
410 |
+
"dependencies": {
|
411 |
+
"tslib": "^2.1.0"
|
412 |
+
}
|
413 |
+
},
|
414 |
+
"node_modules/@formatjs/icu-messageformat-parser": {
|
415 |
+
"version": "2.1.0",
|
416 |
+
"resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.1.0.tgz",
|
417 |
+
"integrity": "sha512-Qxv/lmCN6hKpBSss2uQ8IROVnta2r9jd3ymUEIjm2UyIkUCHVcbUVRGL/KS/wv7876edvsPe+hjHVJ4z8YuVaw==",
|
418 |
+
"dependencies": {
|
419 |
+
"@formatjs/ecma402-abstract": "1.11.4",
|
420 |
+
"@formatjs/icu-skeleton-parser": "1.3.6",
|
421 |
+
"tslib": "^2.1.0"
|
422 |
+
}
|
423 |
+
},
|
424 |
+
"node_modules/@formatjs/icu-skeleton-parser": {
|
425 |
+
"version": "1.3.6",
|
426 |
+
"resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.6.tgz",
|
427 |
+
"integrity": "sha512-I96mOxvml/YLrwU2Txnd4klA7V8fRhb6JG/4hm3VMNmeJo1F03IpV2L3wWt7EweqNLES59SZ4d6hVOPCSf80Bg==",
|
428 |
+
"dependencies": {
|
429 |
+
"@formatjs/ecma402-abstract": "1.11.4",
|
430 |
+
"tslib": "^2.1.0"
|
431 |
+
}
|
432 |
+
},
|
433 |
+
"node_modules/@formatjs/intl-localematcher": {
|
434 |
+
"version": "0.2.25",
|
435 |
+
"resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.2.25.tgz",
|
436 |
+
"integrity": "sha512-YmLcX70BxoSopLFdLr1Ds99NdlTI2oWoLbaUW2M406lxOIPzE1KQhRz2fPUkq34xVZQaihCoU29h0KK7An3bhA==",
|
437 |
+
"dependencies": {
|
438 |
+
"tslib": "^2.1.0"
|
439 |
+
}
|
440 |
+
},
|
441 |
+
"node_modules/@gradio/atoms": {
|
442 |
+
"version": "0.2.1",
|
443 |
+
"resolved": "https://registry.npmjs.org/@gradio/atoms/-/atoms-0.2.1.tgz",
|
444 |
+
"integrity": "sha512-di3kKSbjxKGngvTAaqUaA6whOVs5BFlQULlWDPq1m37VRgUD7Oq2MkIE+T+YiNAhByN93pqA0hGrWwAUUuxy5Q==",
|
445 |
+
"dependencies": {
|
446 |
+
"@gradio/icons": "^0.2.0",
|
447 |
+
"@gradio/utils": "^0.2.0"
|
448 |
+
}
|
449 |
+
},
|
450 |
+
"node_modules/@gradio/button": {
|
451 |
+
"version": "0.2.3",
|
452 |
+
"resolved": "https://registry.npmjs.org/@gradio/button/-/button-0.2.3.tgz",
|
453 |
+
"integrity": "sha512-vbSMcRNrtBKycnAgpCpepKaC4NNAg36I9qbEaz8wKqHqU02oTOaUeyelEitHLWULqLf3+sy6BM+JxxFjtELgXQ==",
|
454 |
+
"dependencies": {
|
455 |
+
"@gradio/client": "^0.7.2",
|
456 |
+
"@gradio/upload": "^0.3.3",
|
457 |
+
"@gradio/utils": "^0.2.0"
|
458 |
+
}
|
459 |
+
},
|
460 |
+
"node_modules/@gradio/client": {
|
461 |
+
"version": "0.7.2",
|
462 |
+
"resolved": "https://registry.npmjs.org/@gradio/client/-/client-0.7.2.tgz",
|
463 |
+
"integrity": "sha512-YkT3c0u38ZYPKvOCmT0xLu3Gau4SwMe1Yo0PNvqTLwHfI4++dp5MJIWH97820MUqgQhYy6V3GmVAliHRmnfPbw==",
|
464 |
+
"dependencies": {
|
465 |
+
"bufferutil": "^4.0.7",
|
466 |
+
"semiver": "^1.1.0",
|
467 |
+
"ws": "^8.13.0"
|
468 |
+
},
|
469 |
+
"engines": {
|
470 |
+
"node": ">=18.0.0"
|
471 |
+
}
|
472 |
+
},
|
473 |
+
"node_modules/@gradio/column": {
|
474 |
+
"version": "0.1.0",
|
475 |
+
"resolved": "https://registry.npmjs.org/@gradio/column/-/column-0.1.0.tgz",
|
476 |
+
"integrity": "sha512-P24nqqVnMXBaDA1f/zSN5HZRho4PxP8Dq+7VltPHlmxIEiZYik2AJ4J0LeuIha34FDO0guu/16evdrpvGIUAfw=="
|
477 |
+
},
|
478 |
+
"node_modules/@gradio/icons": {
|
479 |
+
"version": "0.2.0",
|
480 |
+
"resolved": "https://registry.npmjs.org/@gradio/icons/-/icons-0.2.0.tgz",
|
481 |
+
"integrity": "sha512-rfCSmOF+ALqBOjTWL1ICasyA8JuO0MPwFrtlVMyAWp7R14AN8YChC/gbz5fZ0kNBiGGEYOOfqpKxyvC95jGGlg=="
|
482 |
+
},
|
483 |
+
"node_modules/@gradio/statustracker": {
|
484 |
+
"version": "0.3.1",
|
485 |
+
"resolved": "https://registry.npmjs.org/@gradio/statustracker/-/statustracker-0.3.1.tgz",
|
486 |
+
"integrity": "sha512-ZpmXZSnbgoFU2J54SrNntwfo2OEuEoRV310Q0zGVTH1VL7loziR7GuYhfIbgS8qFlrWM0MhMoLGDX+k7LAig5w==",
|
487 |
+
"dependencies": {
|
488 |
+
"@gradio/atoms": "^0.2.1",
|
489 |
+
"@gradio/column": "^0.1.0",
|
490 |
+
"@gradio/icons": "^0.2.0",
|
491 |
+
"@gradio/utils": "^0.2.0"
|
492 |
+
}
|
493 |
+
},
|
494 |
+
"node_modules/@gradio/theme": {
|
495 |
+
"version": "0.2.0",
|
496 |
+
"resolved": "https://registry.npmjs.org/@gradio/theme/-/theme-0.2.0.tgz",
|
497 |
+
"integrity": "sha512-33c68Nk7oRXLn08OxPfjcPm7S4tXGOUV1I1bVgzdM2YV5o1QBOS1GEnXPZPu/CEYPePLMB6bsDwffrLEyLGWVQ=="
|
498 |
+
},
|
499 |
+
"node_modules/@gradio/upload": {
|
500 |
+
"version": "0.3.3",
|
501 |
+
"resolved": "https://registry.npmjs.org/@gradio/upload/-/upload-0.3.3.tgz",
|
502 |
+
"integrity": "sha512-KWRtH9UTe20u1/14KezuZDEwecLZzjDHdSPDUCrk27SrE6ptV8/qLtefOkg9zE+W51iATxDtQAvi0afLQ8XGrw==",
|
503 |
+
"dependencies": {
|
504 |
+
"@gradio/atoms": "^0.2.1",
|
505 |
+
"@gradio/client": "^0.7.2",
|
506 |
+
"@gradio/icons": "^0.2.0",
|
507 |
+
"@gradio/upload": "^0.3.3",
|
508 |
+
"@gradio/utils": "^0.2.0"
|
509 |
+
}
|
510 |
+
},
|
511 |
+
"node_modules/@gradio/utils": {
|
512 |
+
"version": "0.2.0",
|
513 |
+
"resolved": "https://registry.npmjs.org/@gradio/utils/-/utils-0.2.0.tgz",
|
514 |
+
"integrity": "sha512-YkwzXufi6IxQrlMW+1sFo8Yn6F9NLL69ZoBsbo7QEhms0v5L7pmOTw+dfd7M3dwbRP2lgjrb52i1kAIN3n6aqQ==",
|
515 |
+
"dependencies": {
|
516 |
+
"@gradio/theme": "^0.2.0",
|
517 |
+
"svelte-i18n": "^3.6.0"
|
518 |
+
}
|
519 |
+
},
|
520 |
+
"node_modules/@gradio/wasm": {
|
521 |
+
"version": "0.2.0",
|
522 |
+
"resolved": "https://registry.npmjs.org/@gradio/wasm/-/wasm-0.2.0.tgz",
|
523 |
+
"integrity": "sha512-lU0Uzn4avbyO4AA1yp7IR2FQcO23YUEU3kn0NA8S9cGIZLzxj1FepPO1TsNXtMymDdKKx72TJW2v4yrv/j3H2A==",
|
524 |
+
"dependencies": {
|
525 |
+
"@types/path-browserify": "^1.0.0",
|
526 |
+
"path-browserify": "^1.0.1"
|
527 |
+
}
|
528 |
+
},
|
529 |
+
"node_modules/@jridgewell/gen-mapping": {
|
530 |
+
"version": "0.3.3",
|
531 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz",
|
532 |
+
"integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==",
|
533 |
+
"peer": true,
|
534 |
+
"dependencies": {
|
535 |
+
"@jridgewell/set-array": "^1.0.1",
|
536 |
+
"@jridgewell/sourcemap-codec": "^1.4.10",
|
537 |
+
"@jridgewell/trace-mapping": "^0.3.9"
|
538 |
+
},
|
539 |
+
"engines": {
|
540 |
+
"node": ">=6.0.0"
|
541 |
+
}
|
542 |
+
},
|
543 |
+
"node_modules/@jridgewell/resolve-uri": {
|
544 |
+
"version": "3.1.1",
|
545 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
|
546 |
+
"integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
|
547 |
+
"peer": true,
|
548 |
+
"engines": {
|
549 |
+
"node": ">=6.0.0"
|
550 |
+
}
|
551 |
+
},
|
552 |
+
"node_modules/@jridgewell/set-array": {
|
553 |
+
"version": "1.1.2",
|
554 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz",
|
555 |
+
"integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==",
|
556 |
+
"peer": true,
|
557 |
+
"engines": {
|
558 |
+
"node": ">=6.0.0"
|
559 |
+
}
|
560 |
+
},
|
561 |
+
"node_modules/@jridgewell/sourcemap-codec": {
|
562 |
+
"version": "1.4.15",
|
563 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
|
564 |
+
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
|
565 |
+
"peer": true
|
566 |
+
},
|
567 |
+
"node_modules/@jridgewell/trace-mapping": {
|
568 |
+
"version": "0.3.21",
|
569 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz",
|
570 |
+
"integrity": "sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g==",
|
571 |
+
"peer": true,
|
572 |
+
"dependencies": {
|
573 |
+
"@jridgewell/resolve-uri": "^3.1.0",
|
574 |
+
"@jridgewell/sourcemap-codec": "^1.4.14"
|
575 |
+
}
|
576 |
+
},
|
577 |
+
"node_modules/@types/debounce": {
|
578 |
+
"version": "1.2.4",
|
579 |
+
"resolved": "https://registry.npmjs.org/@types/debounce/-/debounce-1.2.4.tgz",
|
580 |
+
"integrity": "sha512-jBqiORIzKDOToaF63Fm//haOCHuwQuLa2202RK4MozpA6lh93eCBc+/8+wZn5OzjJt3ySdc+74SXWXB55Ewtyw=="
|
581 |
+
},
|
582 |
+
"node_modules/@types/estree": {
|
583 |
+
"version": "1.0.5",
|
584 |
+
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
|
585 |
+
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
|
586 |
+
"peer": true
|
587 |
+
},
|
588 |
+
"node_modules/@types/path-browserify": {
|
589 |
+
"version": "1.0.2",
|
590 |
+
"resolved": "https://registry.npmjs.org/@types/path-browserify/-/path-browserify-1.0.2.tgz",
|
591 |
+
"integrity": "sha512-ZkC5IUqqIFPXx3ASTTybTzmQdwHwe2C0u3eL75ldQ6T9E9IWFJodn6hIfbZGab73DfyiHN4Xw15gNxUq2FbvBA=="
|
592 |
+
},
|
593 |
+
"node_modules/@types/wavesurfer.js": {
|
594 |
+
"version": "6.0.12",
|
595 |
+
"resolved": "https://registry.npmjs.org/@types/wavesurfer.js/-/wavesurfer.js-6.0.12.tgz",
|
596 |
+
"integrity": "sha512-oM9hYlPIVms4uwwoaGs9d0qp7Xk7IjSGkdwgmhUymVUIIilRfjtSQvoOgv4dpKiW0UozWRSyXfQqTobi0qWyCw==",
|
597 |
+
"dependencies": {
|
598 |
+
"@types/debounce": "*"
|
599 |
+
}
|
600 |
+
},
|
601 |
+
"node_modules/acorn": {
|
602 |
+
"version": "8.11.3",
|
603 |
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
604 |
+
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
605 |
+
"peer": true,
|
606 |
+
"bin": {
|
607 |
+
"acorn": "bin/acorn"
|
608 |
+
},
|
609 |
+
"engines": {
|
610 |
+
"node": ">=0.4.0"
|
611 |
+
}
|
612 |
+
},
|
613 |
+
"node_modules/aria-query": {
|
614 |
+
"version": "5.3.0",
|
615 |
+
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
|
616 |
+
"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
|
617 |
+
"peer": true,
|
618 |
+
"dependencies": {
|
619 |
+
"dequal": "^2.0.3"
|
620 |
+
}
|
621 |
+
},
|
622 |
+
"node_modules/automation-events": {
|
623 |
+
"version": "6.0.13",
|
624 |
+
"resolved": "https://registry.npmjs.org/automation-events/-/automation-events-6.0.13.tgz",
|
625 |
+
"integrity": "sha512-V1D19taPDEB7LUph6FpJv9m2i+UpLR096sAbPKt92sRChCOA6Jt2bcofU/YAwG8F8/qZp3GrrscJ1FzaEHd68w==",
|
626 |
+
"dependencies": {
|
627 |
+
"@babel/runtime": "^7.23.5",
|
628 |
+
"tslib": "^2.6.2"
|
629 |
+
},
|
630 |
+
"engines": {
|
631 |
+
"node": ">=16.1.0"
|
632 |
+
}
|
633 |
+
},
|
634 |
+
"node_modules/axobject-query": {
|
635 |
+
"version": "3.2.1",
|
636 |
+
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz",
|
637 |
+
"integrity": "sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==",
|
638 |
+
"peer": true,
|
639 |
+
"dependencies": {
|
640 |
+
"dequal": "^2.0.3"
|
641 |
+
}
|
642 |
+
},
|
643 |
+
"node_modules/broker-factory": {
|
644 |
+
"version": "3.0.89",
|
645 |
+
"resolved": "https://registry.npmjs.org/broker-factory/-/broker-factory-3.0.89.tgz",
|
646 |
+
"integrity": "sha512-A2zkxJjpWjItTGzIETq7MFtBD6UgSA1VvfAeJIXsI+gq1nQ0VozuP80iZRXgdwRfFBCDdlB+8rzMO8Bfnwirug==",
|
647 |
+
"dependencies": {
|
648 |
+
"@babel/runtime": "^7.23.5",
|
649 |
+
"fast-unique-numbers": "^8.0.12",
|
650 |
+
"tslib": "^2.6.2",
|
651 |
+
"worker-factory": "^7.0.15"
|
652 |
+
}
|
653 |
+
},
|
654 |
+
"node_modules/bufferutil": {
|
655 |
+
"version": "4.0.8",
|
656 |
+
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz",
|
657 |
+
"integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==",
|
658 |
+
"hasInstallScript": true,
|
659 |
+
"dependencies": {
|
660 |
+
"node-gyp-build": "^4.3.0"
|
661 |
+
},
|
662 |
+
"engines": {
|
663 |
+
"node": ">=6.14.2"
|
664 |
+
}
|
665 |
+
},
|
666 |
+
"node_modules/cli-color": {
|
667 |
+
"version": "2.0.3",
|
668 |
+
"resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz",
|
669 |
+
"integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==",
|
670 |
+
"dependencies": {
|
671 |
+
"d": "^1.0.1",
|
672 |
+
"es5-ext": "^0.10.61",
|
673 |
+
"es6-iterator": "^2.0.3",
|
674 |
+
"memoizee": "^0.4.15",
|
675 |
+
"timers-ext": "^0.1.7"
|
676 |
+
},
|
677 |
+
"engines": {
|
678 |
+
"node": ">=0.10"
|
679 |
+
}
|
680 |
+
},
|
681 |
+
"node_modules/code-red": {
|
682 |
+
"version": "1.0.4",
|
683 |
+
"resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz",
|
684 |
+
"integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==",
|
685 |
+
"peer": true,
|
686 |
+
"dependencies": {
|
687 |
+
"@jridgewell/sourcemap-codec": "^1.4.15",
|
688 |
+
"@types/estree": "^1.0.1",
|
689 |
+
"acorn": "^8.10.0",
|
690 |
+
"estree-walker": "^3.0.3",
|
691 |
+
"periscopic": "^3.1.0"
|
692 |
+
}
|
693 |
+
},
|
694 |
+
"node_modules/compilerr": {
|
695 |
+
"version": "11.0.13",
|
696 |
+
"resolved": "https://registry.npmjs.org/compilerr/-/compilerr-11.0.13.tgz",
|
697 |
+
"integrity": "sha512-lqq1b3pFfn1Qims/lgzD5+uwOMzrDsUpiZ5LP2v8Sok7K+OFRt+m23GmkTBQl6ONvFSTB+xL1be8GXYsxt5dJQ==",
|
698 |
+
"dependencies": {
|
699 |
+
"@babel/runtime": "^7.23.5",
|
700 |
+
"dashify": "^2.0.0",
|
701 |
+
"indefinite-article": "0.0.2",
|
702 |
+
"tslib": "^2.6.2"
|
703 |
+
},
|
704 |
+
"engines": {
|
705 |
+
"node": ">=16.1.0"
|
706 |
+
}
|
707 |
+
},
|
708 |
+
"node_modules/css-tree": {
|
709 |
+
"version": "2.3.1",
|
710 |
+
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz",
|
711 |
+
"integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==",
|
712 |
+
"peer": true,
|
713 |
+
"dependencies": {
|
714 |
+
"mdn-data": "2.0.30",
|
715 |
+
"source-map-js": "^1.0.1"
|
716 |
+
},
|
717 |
+
"engines": {
|
718 |
+
"node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"
|
719 |
+
}
|
720 |
+
},
|
721 |
+
"node_modules/d": {
|
722 |
+
"version": "1.0.1",
|
723 |
+
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
724 |
+
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
725 |
+
"dependencies": {
|
726 |
+
"es5-ext": "^0.10.50",
|
727 |
+
"type": "^1.0.1"
|
728 |
+
}
|
729 |
+
},
|
730 |
+
"node_modules/dashify": {
|
731 |
+
"version": "2.0.0",
|
732 |
+
"resolved": "https://registry.npmjs.org/dashify/-/dashify-2.0.0.tgz",
|
733 |
+
"integrity": "sha512-hpA5C/YrPjucXypHPPc0oJ1l9Hf6wWbiOL7Ik42cxnsUOhWiCB/fylKbKqqJalW9FgkNQCw16YO8uW9Hs0Iy1A==",
|
734 |
+
"engines": {
|
735 |
+
"node": ">=4"
|
736 |
+
}
|
737 |
+
},
|
738 |
+
"node_modules/deepmerge": {
|
739 |
+
"version": "4.3.1",
|
740 |
+
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
|
741 |
+
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
|
742 |
+
"engines": {
|
743 |
+
"node": ">=0.10.0"
|
744 |
+
}
|
745 |
+
},
|
746 |
+
"node_modules/dequal": {
|
747 |
+
"version": "2.0.3",
|
748 |
+
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
|
749 |
+
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
|
750 |
+
"peer": true,
|
751 |
+
"engines": {
|
752 |
+
"node": ">=6"
|
753 |
+
}
|
754 |
+
},
|
755 |
+
"node_modules/es5-ext": {
|
756 |
+
"version": "0.10.62",
|
757 |
+
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz",
|
758 |
+
"integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==",
|
759 |
+
"hasInstallScript": true,
|
760 |
+
"dependencies": {
|
761 |
+
"es6-iterator": "^2.0.3",
|
762 |
+
"es6-symbol": "^3.1.3",
|
763 |
+
"next-tick": "^1.1.0"
|
764 |
+
},
|
765 |
+
"engines": {
|
766 |
+
"node": ">=0.10"
|
767 |
+
}
|
768 |
+
},
|
769 |
+
"node_modules/es6-iterator": {
|
770 |
+
"version": "2.0.3",
|
771 |
+
"resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
|
772 |
+
"integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
|
773 |
+
"dependencies": {
|
774 |
+
"d": "1",
|
775 |
+
"es5-ext": "^0.10.35",
|
776 |
+
"es6-symbol": "^3.1.1"
|
777 |
+
}
|
778 |
+
},
|
779 |
+
"node_modules/es6-symbol": {
|
780 |
+
"version": "3.1.3",
|
781 |
+
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
|
782 |
+
"integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
|
783 |
+
"dependencies": {
|
784 |
+
"d": "^1.0.1",
|
785 |
+
"ext": "^1.1.2"
|
786 |
+
}
|
787 |
+
},
|
788 |
+
"node_modules/es6-weak-map": {
|
789 |
+
"version": "2.0.3",
|
790 |
+
"resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz",
|
791 |
+
"integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==",
|
792 |
+
"dependencies": {
|
793 |
+
"d": "1",
|
794 |
+
"es5-ext": "^0.10.46",
|
795 |
+
"es6-iterator": "^2.0.3",
|
796 |
+
"es6-symbol": "^3.1.1"
|
797 |
+
}
|
798 |
+
},
|
799 |
+
"node_modules/esbuild": {
|
800 |
+
"version": "0.19.11",
|
801 |
+
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.11.tgz",
|
802 |
+
"integrity": "sha512-HJ96Hev2hX/6i5cDVwcqiJBBtuo9+FeIJOtZ9W1kA5M6AMJRHUZlpYZ1/SbEwtO0ioNAW8rUooVpC/WehY2SfA==",
|
803 |
+
"hasInstallScript": true,
|
804 |
+
"bin": {
|
805 |
+
"esbuild": "bin/esbuild"
|
806 |
+
},
|
807 |
+
"engines": {
|
808 |
+
"node": ">=12"
|
809 |
+
},
|
810 |
+
"optionalDependencies": {
|
811 |
+
"@esbuild/aix-ppc64": "0.19.11",
|
812 |
+
"@esbuild/android-arm": "0.19.11",
|
813 |
+
"@esbuild/android-arm64": "0.19.11",
|
814 |
+
"@esbuild/android-x64": "0.19.11",
|
815 |
+
"@esbuild/darwin-arm64": "0.19.11",
|
816 |
+
"@esbuild/darwin-x64": "0.19.11",
|
817 |
+
"@esbuild/freebsd-arm64": "0.19.11",
|
818 |
+
"@esbuild/freebsd-x64": "0.19.11",
|
819 |
+
"@esbuild/linux-arm": "0.19.11",
|
820 |
+
"@esbuild/linux-arm64": "0.19.11",
|
821 |
+
"@esbuild/linux-ia32": "0.19.11",
|
822 |
+
"@esbuild/linux-loong64": "0.19.11",
|
823 |
+
"@esbuild/linux-mips64el": "0.19.11",
|
824 |
+
"@esbuild/linux-ppc64": "0.19.11",
|
825 |
+
"@esbuild/linux-riscv64": "0.19.11",
|
826 |
+
"@esbuild/linux-s390x": "0.19.11",
|
827 |
+
"@esbuild/linux-x64": "0.19.11",
|
828 |
+
"@esbuild/netbsd-x64": "0.19.11",
|
829 |
+
"@esbuild/openbsd-x64": "0.19.11",
|
830 |
+
"@esbuild/sunos-x64": "0.19.11",
|
831 |
+
"@esbuild/win32-arm64": "0.19.11",
|
832 |
+
"@esbuild/win32-ia32": "0.19.11",
|
833 |
+
"@esbuild/win32-x64": "0.19.11"
|
834 |
+
}
|
835 |
+
},
|
836 |
+
"node_modules/estree-walker": {
|
837 |
+
"version": "3.0.3",
|
838 |
+
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
|
839 |
+
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
|
840 |
+
"peer": true,
|
841 |
+
"dependencies": {
|
842 |
+
"@types/estree": "^1.0.0"
|
843 |
+
}
|
844 |
+
},
|
845 |
+
"node_modules/event-emitter": {
|
846 |
+
"version": "0.3.5",
|
847 |
+
"resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
|
848 |
+
"integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==",
|
849 |
+
"dependencies": {
|
850 |
+
"d": "1",
|
851 |
+
"es5-ext": "~0.10.14"
|
852 |
+
}
|
853 |
+
},
|
854 |
+
"node_modules/ext": {
|
855 |
+
"version": "1.7.0",
|
856 |
+
"resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz",
|
857 |
+
"integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==",
|
858 |
+
"dependencies": {
|
859 |
+
"type": "^2.7.2"
|
860 |
+
}
|
861 |
+
},
|
862 |
+
"node_modules/ext/node_modules/type": {
|
863 |
+
"version": "2.7.2",
|
864 |
+
"resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
|
865 |
+
"integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
|
866 |
+
},
|
867 |
+
"node_modules/extendable-media-recorder": {
|
868 |
+
"version": "9.1.6",
|
869 |
+
"resolved": "https://registry.npmjs.org/extendable-media-recorder/-/extendable-media-recorder-9.1.6.tgz",
|
870 |
+
"integrity": "sha512-gMrwE9zI3PVkh8blBzDGj0mIukiHrlqAL0r05C88jseWyiy7qhaClcWPaYisu81gTRhiI/NdRalo9wB4h7MKLg==",
|
871 |
+
"dependencies": {
|
872 |
+
"@babel/runtime": "^7.23.7",
|
873 |
+
"media-encoder-host": "^8.0.104",
|
874 |
+
"multi-buffer-data-view": "^5.0.13",
|
875 |
+
"recorder-audio-worklet": "^6.0.17",
|
876 |
+
"standardized-audio-context": "^25.3.61",
|
877 |
+
"subscribable-things": "^2.1.28",
|
878 |
+
"tslib": "^2.6.2"
|
879 |
+
}
|
880 |
+
},
|
881 |
+
"node_modules/extendable-media-recorder-wav-encoder": {
|
882 |
+
"version": "7.0.101",
|
883 |
+
"resolved": "https://registry.npmjs.org/extendable-media-recorder-wav-encoder/-/extendable-media-recorder-wav-encoder-7.0.101.tgz",
|
884 |
+
"integrity": "sha512-Q0qc4R5tWwT2eEezo/fDtg5rjkIvmlESpDLXnN41O8N598LkXfUm34H9iONHEAKVo3kM0RG5KS4mFAb1iDMQkQ==",
|
885 |
+
"dependencies": {
|
886 |
+
"@babel/runtime": "^7.23.5",
|
887 |
+
"extendable-media-recorder-wav-encoder-broker": "^7.0.93",
|
888 |
+
"extendable-media-recorder-wav-encoder-worker": "^8.0.90",
|
889 |
+
"tslib": "^2.6.2"
|
890 |
+
}
|
891 |
+
},
|
892 |
+
"node_modules/extendable-media-recorder-wav-encoder-broker": {
|
893 |
+
"version": "7.0.93",
|
894 |
+
"resolved": "https://registry.npmjs.org/extendable-media-recorder-wav-encoder-broker/-/extendable-media-recorder-wav-encoder-broker-7.0.93.tgz",
|
895 |
+
"integrity": "sha512-mZQlQ9Yyt3/x3vO6apu5hR49RdLCtHVEqjmf3PSi5nPtrQSJKI5n3oUp9v4jRNAJbUCxtRmBZHDZ2HvwHfDtbQ==",
|
896 |
+
"dependencies": {
|
897 |
+
"@babel/runtime": "^7.23.5",
|
898 |
+
"broker-factory": "^3.0.89",
|
899 |
+
"extendable-media-recorder-wav-encoder-worker": "^8.0.90",
|
900 |
+
"tslib": "^2.6.2"
|
901 |
+
}
|
902 |
+
},
|
903 |
+
"node_modules/extendable-media-recorder-wav-encoder-worker": {
|
904 |
+
"version": "8.0.90",
|
905 |
+
"resolved": "https://registry.npmjs.org/extendable-media-recorder-wav-encoder-worker/-/extendable-media-recorder-wav-encoder-worker-8.0.90.tgz",
|
906 |
+
"integrity": "sha512-13X3svoPjAlOmIWtRSyMC354vZF82GXhQnI2fHwp41k7hQCS1jaQ8WlUMzcyZ2GAKErbuzWAdVuKPLedNpQUDA==",
|
907 |
+
"dependencies": {
|
908 |
+
"@babel/runtime": "^7.23.5",
|
909 |
+
"tslib": "^2.6.2",
|
910 |
+
"worker-factory": "^7.0.15"
|
911 |
+
}
|
912 |
+
},
|
913 |
+
"node_modules/fast-unique-numbers": {
|
914 |
+
"version": "8.0.12",
|
915 |
+
"resolved": "https://registry.npmjs.org/fast-unique-numbers/-/fast-unique-numbers-8.0.12.tgz",
|
916 |
+
"integrity": "sha512-Z4AJueNDnuC/sLxeQqrHP4zgqcBIeQQLbQ0hEx1a7m6Wf7ERrdAyR7CkGfoEFWm9Qla7dpLt0eWPyiO18gqj0A==",
|
917 |
+
"dependencies": {
|
918 |
+
"@babel/runtime": "^7.23.5",
|
919 |
+
"tslib": "^2.6.2"
|
920 |
+
},
|
921 |
+
"engines": {
|
922 |
+
"node": ">=16.1.0"
|
923 |
+
}
|
924 |
+
},
|
925 |
+
"node_modules/globalyzer": {
|
926 |
+
"version": "0.1.0",
|
927 |
+
"resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
|
928 |
+
"integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q=="
|
929 |
+
},
|
930 |
+
"node_modules/globrex": {
|
931 |
+
"version": "0.1.2",
|
932 |
+
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
|
933 |
+
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
|
934 |
+
},
|
935 |
+
"node_modules/indefinite-article": {
|
936 |
+
"version": "0.0.2",
|
937 |
+
"resolved": "https://registry.npmjs.org/indefinite-article/-/indefinite-article-0.0.2.tgz",
|
938 |
+
"integrity": "sha512-Au/2XzRkvxq2J6w5uvSSbBKPZ5kzINx5F2wb0SF8xpRL8BP9Lav81TnRbfPp6p+SYjYxwaaLn4EUwI3/MmYKSw=="
|
939 |
+
},
|
940 |
+
"node_modules/intl-messageformat": {
|
941 |
+
"version": "9.13.0",
|
942 |
+
"resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-9.13.0.tgz",
|
943 |
+
"integrity": "sha512-7sGC7QnSQGa5LZP7bXLDhVDtQOeKGeBFGHF2Y8LVBwYZoQZCgWeKoPGTa5GMG8g/TzDgeXuYJQis7Ggiw2xTOw==",
|
944 |
+
"dependencies": {
|
945 |
+
"@formatjs/ecma402-abstract": "1.11.4",
|
946 |
+
"@formatjs/fast-memoize": "1.2.1",
|
947 |
+
"@formatjs/icu-messageformat-parser": "2.1.0",
|
948 |
+
"tslib": "^2.1.0"
|
949 |
+
}
|
950 |
+
},
|
951 |
+
"node_modules/is-promise": {
|
952 |
+
"version": "2.2.2",
|
953 |
+
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
|
954 |
+
"integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ=="
|
955 |
+
},
|
956 |
+
"node_modules/is-reference": {
|
957 |
+
"version": "3.0.2",
|
958 |
+
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz",
|
959 |
+
"integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==",
|
960 |
+
"peer": true,
|
961 |
+
"dependencies": {
|
962 |
+
"@types/estree": "*"
|
963 |
+
}
|
964 |
+
},
|
965 |
+
"node_modules/locate-character": {
|
966 |
+
"version": "3.0.0",
|
967 |
+
"resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",
|
968 |
+
"integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
|
969 |
+
"peer": true
|
970 |
+
},
|
971 |
+
"node_modules/lru-queue": {
|
972 |
+
"version": "0.1.0",
|
973 |
+
"resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
|
974 |
+
"integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==",
|
975 |
+
"dependencies": {
|
976 |
+
"es5-ext": "~0.10.2"
|
977 |
+
}
|
978 |
+
},
|
979 |
+
"node_modules/magic-string": {
|
980 |
+
"version": "0.30.5",
|
981 |
+
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz",
|
982 |
+
"integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==",
|
983 |
+
"peer": true,
|
984 |
+
"dependencies": {
|
985 |
+
"@jridgewell/sourcemap-codec": "^1.4.15"
|
986 |
+
},
|
987 |
+
"engines": {
|
988 |
+
"node": ">=12"
|
989 |
+
}
|
990 |
+
},
|
991 |
+
"node_modules/mdn-data": {
|
992 |
+
"version": "2.0.30",
|
993 |
+
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz",
|
994 |
+
"integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==",
|
995 |
+
"peer": true
|
996 |
+
},
|
997 |
+
"node_modules/media-encoder-host": {
|
998 |
+
"version": "8.0.104",
|
999 |
+
"resolved": "https://registry.npmjs.org/media-encoder-host/-/media-encoder-host-8.0.104.tgz",
|
1000 |
+
"integrity": "sha512-DXOm4XbwCKWoCtW2B4leb9YAfC/1HxG8ysT5AOFXNPs5E9UuamDCa0zhtRNPNn2Bp3MJCiB1qo8jORhqVubJhQ==",
|
1001 |
+
"dependencies": {
|
1002 |
+
"@babel/runtime": "^7.23.5",
|
1003 |
+
"media-encoder-host-broker": "^7.0.94",
|
1004 |
+
"media-encoder-host-worker": "^9.1.16",
|
1005 |
+
"tslib": "^2.6.2"
|
1006 |
+
}
|
1007 |
+
},
|
1008 |
+
"node_modules/media-encoder-host-broker": {
|
1009 |
+
"version": "7.0.94",
|
1010 |
+
"resolved": "https://registry.npmjs.org/media-encoder-host-broker/-/media-encoder-host-broker-7.0.94.tgz",
|
1011 |
+
"integrity": "sha512-M3nBVELYCSaVIQWaClYcnAC5ygCSBnfUCbxkcEhPWg+tYgvMlPwDq7unHS6UZI7uecVwyRTN31IL/wa31x0VEg==",
|
1012 |
+
"dependencies": {
|
1013 |
+
"@babel/runtime": "^7.23.5",
|
1014 |
+
"broker-factory": "^3.0.89",
|
1015 |
+
"fast-unique-numbers": "^8.0.12",
|
1016 |
+
"media-encoder-host-worker": "^9.1.16",
|
1017 |
+
"tslib": "^2.6.2"
|
1018 |
+
}
|
1019 |
+
},
|
1020 |
+
"node_modules/media-encoder-host-worker": {
|
1021 |
+
"version": "9.1.16",
|
1022 |
+
"resolved": "https://registry.npmjs.org/media-encoder-host-worker/-/media-encoder-host-worker-9.1.16.tgz",
|
1023 |
+
"integrity": "sha512-L1rD1DXoSLxRhgN52cKwNzzqAIo1y+SXSFKzn+Fj5fFNldOCn4wl4BbuPN6u4HW4yHRzxa6mupTjVaKumiw7uw==",
|
1024 |
+
"dependencies": {
|
1025 |
+
"@babel/runtime": "^7.23.5",
|
1026 |
+
"extendable-media-recorder-wav-encoder-broker": "^7.0.93",
|
1027 |
+
"tslib": "^2.6.2",
|
1028 |
+
"worker-factory": "^7.0.15"
|
1029 |
+
}
|
1030 |
+
},
|
1031 |
+
"node_modules/memoizee": {
|
1032 |
+
"version": "0.4.15",
|
1033 |
+
"resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz",
|
1034 |
+
"integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==",
|
1035 |
+
"dependencies": {
|
1036 |
+
"d": "^1.0.1",
|
1037 |
+
"es5-ext": "^0.10.53",
|
1038 |
+
"es6-weak-map": "^2.0.3",
|
1039 |
+
"event-emitter": "^0.3.5",
|
1040 |
+
"is-promise": "^2.2.2",
|
1041 |
+
"lru-queue": "^0.1.0",
|
1042 |
+
"next-tick": "^1.1.0",
|
1043 |
+
"timers-ext": "^0.1.7"
|
1044 |
+
}
|
1045 |
+
},
|
1046 |
+
"node_modules/mri": {
|
1047 |
+
"version": "1.2.0",
|
1048 |
+
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
1049 |
+
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
|
1050 |
+
"engines": {
|
1051 |
+
"node": ">=4"
|
1052 |
+
}
|
1053 |
+
},
|
1054 |
+
"node_modules/multi-buffer-data-view": {
|
1055 |
+
"version": "5.0.13",
|
1056 |
+
"resolved": "https://registry.npmjs.org/multi-buffer-data-view/-/multi-buffer-data-view-5.0.13.tgz",
|
1057 |
+
"integrity": "sha512-1aR8uZp6JOEq1tb1euDmCZFm0ksOe8Kub3ItBrDPBKVhlPaknUcAhanDxrSVrJiJb5c+4vsB1U6Tye8AbL9XkQ==",
|
1058 |
+
"dependencies": {
|
1059 |
+
"@babel/runtime": "^7.23.5",
|
1060 |
+
"tslib": "^2.6.2"
|
1061 |
+
},
|
1062 |
+
"engines": {
|
1063 |
+
"node": ">=16.1.0"
|
1064 |
+
}
|
1065 |
+
},
|
1066 |
+
"node_modules/next-tick": {
|
1067 |
+
"version": "1.1.0",
|
1068 |
+
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
|
1069 |
+
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
1070 |
+
},
|
1071 |
+
"node_modules/node-gyp-build": {
|
1072 |
+
"version": "4.8.0",
|
1073 |
+
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.0.tgz",
|
1074 |
+
"integrity": "sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==",
|
1075 |
+
"bin": {
|
1076 |
+
"node-gyp-build": "bin.js",
|
1077 |
+
"node-gyp-build-optional": "optional.js",
|
1078 |
+
"node-gyp-build-test": "build-test.js"
|
1079 |
+
}
|
1080 |
+
},
|
1081 |
+
"node_modules/path-browserify": {
|
1082 |
+
"version": "1.0.1",
|
1083 |
+
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz",
|
1084 |
+
"integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g=="
|
1085 |
+
},
|
1086 |
+
"node_modules/periscopic": {
|
1087 |
+
"version": "3.1.0",
|
1088 |
+
"resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz",
|
1089 |
+
"integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==",
|
1090 |
+
"peer": true,
|
1091 |
+
"dependencies": {
|
1092 |
+
"@types/estree": "^1.0.0",
|
1093 |
+
"estree-walker": "^3.0.0",
|
1094 |
+
"is-reference": "^3.0.0"
|
1095 |
+
}
|
1096 |
+
},
|
1097 |
+
"node_modules/recorder-audio-worklet": {
|
1098 |
+
"version": "6.0.17",
|
1099 |
+
"resolved": "https://registry.npmjs.org/recorder-audio-worklet/-/recorder-audio-worklet-6.0.17.tgz",
|
1100 |
+
"integrity": "sha512-SlK6XYwDonSUKUE6OBj+cwZhqzY7Pz3Eiv4dAFfuR5npOHHfj/mvSadmkhk5r6KltZ6aCgXoPNtGYDH6BchXwA==",
|
1101 |
+
"dependencies": {
|
1102 |
+
"@babel/runtime": "^7.23.5",
|
1103 |
+
"broker-factory": "^3.0.89",
|
1104 |
+
"fast-unique-numbers": "^8.0.12",
|
1105 |
+
"recorder-audio-worklet-processor": "^5.0.12",
|
1106 |
+
"standardized-audio-context": "^25.3.60",
|
1107 |
+
"subscribable-things": "^2.1.28",
|
1108 |
+
"tslib": "^2.6.2",
|
1109 |
+
"worker-factory": "^7.0.15"
|
1110 |
+
}
|
1111 |
+
},
|
1112 |
+
"node_modules/recorder-audio-worklet-processor": {
|
1113 |
+
"version": "5.0.12",
|
1114 |
+
"resolved": "https://registry.npmjs.org/recorder-audio-worklet-processor/-/recorder-audio-worklet-processor-5.0.12.tgz",
|
1115 |
+
"integrity": "sha512-t8PUAo8au5MaxXaofhCCGGYntYm8dJkM4uGz6IQ3VXv29eoLRPAURKUNRCG/rufdwKm21X6LyxulEsWoL+x/EQ==",
|
1116 |
+
"dependencies": {
|
1117 |
+
"@babel/runtime": "^7.23.5",
|
1118 |
+
"tslib": "^2.6.2"
|
1119 |
+
}
|
1120 |
+
},
|
1121 |
+
"node_modules/regenerator-runtime": {
|
1122 |
+
"version": "0.14.1",
|
1123 |
+
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
|
1124 |
+
"integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw=="
|
1125 |
+
},
|
1126 |
+
"node_modules/resize-observer-polyfill": {
|
1127 |
+
"version": "1.5.1",
|
1128 |
+
"resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
|
1129 |
+
"integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg=="
|
1130 |
+
},
|
1131 |
+
"node_modules/rxjs-interop": {
|
1132 |
+
"version": "2.0.0",
|
1133 |
+
"resolved": "https://registry.npmjs.org/rxjs-interop/-/rxjs-interop-2.0.0.tgz",
|
1134 |
+
"integrity": "sha512-ASEq9atUw7lualXB+knvgtvwkCEvGWV2gDD/8qnASzBkzEARZck9JAyxmY8OS6Nc1pCPEgDTKNcx+YqqYfzArw=="
|
1135 |
+
},
|
1136 |
+
"node_modules/sade": {
|
1137 |
+
"version": "1.8.1",
|
1138 |
+
"resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
|
1139 |
+
"integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
|
1140 |
+
"dependencies": {
|
1141 |
+
"mri": "^1.1.0"
|
1142 |
+
},
|
1143 |
+
"engines": {
|
1144 |
+
"node": ">=6"
|
1145 |
+
}
|
1146 |
+
},
|
1147 |
+
"node_modules/semiver": {
|
1148 |
+
"version": "1.1.0",
|
1149 |
+
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
|
1150 |
+
"integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==",
|
1151 |
+
"engines": {
|
1152 |
+
"node": ">=6"
|
1153 |
+
}
|
1154 |
+
},
|
1155 |
+
"node_modules/source-map-js": {
|
1156 |
+
"version": "1.0.2",
|
1157 |
+
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
|
1158 |
+
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
|
1159 |
+
"peer": true,
|
1160 |
+
"engines": {
|
1161 |
+
"node": ">=0.10.0"
|
1162 |
+
}
|
1163 |
+
},
|
1164 |
+
"node_modules/standardized-audio-context": {
|
1165 |
+
"version": "25.3.61",
|
1166 |
+
"resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.61.tgz",
|
1167 |
+
"integrity": "sha512-ew5s1DOlSfU/oHtdIbRGhtPriGd2D4ttVY0uB63Ura1bQWG+c0YVFtmy2fBPLcKH5qkIbrHHlwJTikgVsJ62dg==",
|
1168 |
+
"dependencies": {
|
1169 |
+
"@babel/runtime": "^7.23.6",
|
1170 |
+
"automation-events": "^6.0.13",
|
1171 |
+
"tslib": "^2.6.2"
|
1172 |
+
}
|
1173 |
+
},
|
1174 |
+
"node_modules/subscribable-things": {
|
1175 |
+
"version": "2.1.28",
|
1176 |
+
"resolved": "https://registry.npmjs.org/subscribable-things/-/subscribable-things-2.1.28.tgz",
|
1177 |
+
"integrity": "sha512-uZipZJ2/EyClGZZSDsRMXBpvDvK18QCKBc42b6fT9TYNFSjwy7+GEWWkxeFY+jCpXhgfrd3CnrQ2reinhFn8yw==",
|
1178 |
+
"dependencies": {
|
1179 |
+
"@babel/runtime": "^7.23.5",
|
1180 |
+
"rxjs-interop": "^2.0.0",
|
1181 |
+
"tslib": "^2.6.2"
|
1182 |
+
}
|
1183 |
+
},
|
1184 |
+
"node_modules/svelte": {
|
1185 |
+
"version": "4.2.8",
|
1186 |
+
"resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.8.tgz",
|
1187 |
+
"integrity": "sha512-hU6dh1MPl8gh6klQZwK/n73GiAHiR95IkFsesLPbMeEZi36ydaXL/ZAb4g9sayT0MXzpxyZjR28yderJHxcmYA==",
|
1188 |
+
"peer": true,
|
1189 |
+
"dependencies": {
|
1190 |
+
"@ampproject/remapping": "^2.2.1",
|
1191 |
+
"@jridgewell/sourcemap-codec": "^1.4.15",
|
1192 |
+
"@jridgewell/trace-mapping": "^0.3.18",
|
1193 |
+
"acorn": "^8.9.0",
|
1194 |
+
"aria-query": "^5.3.0",
|
1195 |
+
"axobject-query": "^3.2.1",
|
1196 |
+
"code-red": "^1.0.3",
|
1197 |
+
"css-tree": "^2.3.1",
|
1198 |
+
"estree-walker": "^3.0.3",
|
1199 |
+
"is-reference": "^3.0.1",
|
1200 |
+
"locate-character": "^3.0.0",
|
1201 |
+
"magic-string": "^0.30.4",
|
1202 |
+
"periscopic": "^3.1.0"
|
1203 |
+
},
|
1204 |
+
"engines": {
|
1205 |
+
"node": ">=16"
|
1206 |
+
}
|
1207 |
+
},
|
1208 |
+
"node_modules/svelte-i18n": {
|
1209 |
+
"version": "3.7.4",
|
1210 |
+
"resolved": "https://registry.npmjs.org/svelte-i18n/-/svelte-i18n-3.7.4.tgz",
|
1211 |
+
"integrity": "sha512-yGRCNo+eBT4cPuU7IVsYTYjxB7I2V8qgUZPlHnNctJj5IgbJgV78flsRzpjZ/8iUYZrS49oCt7uxlU3AZv/N5Q==",
|
1212 |
+
"dependencies": {
|
1213 |
+
"cli-color": "^2.0.3",
|
1214 |
+
"deepmerge": "^4.2.2",
|
1215 |
+
"esbuild": "^0.19.2",
|
1216 |
+
"estree-walker": "^2",
|
1217 |
+
"intl-messageformat": "^9.13.0",
|
1218 |
+
"sade": "^1.8.1",
|
1219 |
+
"tiny-glob": "^0.2.9"
|
1220 |
+
},
|
1221 |
+
"bin": {
|
1222 |
+
"svelte-i18n": "dist/cli.js"
|
1223 |
+
},
|
1224 |
+
"engines": {
|
1225 |
+
"node": ">= 16"
|
1226 |
+
},
|
1227 |
+
"peerDependencies": {
|
1228 |
+
"svelte": "^3 || ^4"
|
1229 |
+
}
|
1230 |
+
},
|
1231 |
+
"node_modules/svelte-i18n/node_modules/estree-walker": {
|
1232 |
+
"version": "2.0.2",
|
1233 |
+
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
1234 |
+
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
|
1235 |
+
},
|
1236 |
+
"node_modules/svelte-range-slider-pips": {
|
1237 |
+
"version": "2.2.3",
|
1238 |
+
"resolved": "https://registry.npmjs.org/svelte-range-slider-pips/-/svelte-range-slider-pips-2.2.3.tgz",
|
1239 |
+
"integrity": "sha512-ZAwX9+NDOE6cdqUTMfwBw27YI7NFgSXyPS1ARx3Zuaish2q6FuAtgx5d9+uqNzxQ7WVFhxgM7iQp8MvCpvy4Jw=="
|
1240 |
+
},
|
1241 |
+
"node_modules/timers-ext": {
|
1242 |
+
"version": "0.1.7",
|
1243 |
+
"resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
|
1244 |
+
"integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
|
1245 |
+
"dependencies": {
|
1246 |
+
"es5-ext": "~0.10.46",
|
1247 |
+
"next-tick": "1"
|
1248 |
+
}
|
1249 |
+
},
|
1250 |
+
"node_modules/tiny-glob": {
|
1251 |
+
"version": "0.2.9",
|
1252 |
+
"resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
|
1253 |
+
"integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
|
1254 |
+
"dependencies": {
|
1255 |
+
"globalyzer": "0.1.0",
|
1256 |
+
"globrex": "^0.1.2"
|
1257 |
+
}
|
1258 |
+
},
|
1259 |
+
"node_modules/tslib": {
|
1260 |
+
"version": "2.6.2",
|
1261 |
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
1262 |
+
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
1263 |
+
},
|
1264 |
+
"node_modules/type": {
|
1265 |
+
"version": "1.2.0",
|
1266 |
+
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
1267 |
+
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
1268 |
+
},
|
1269 |
+
"node_modules/wavesurfer.js": {
|
1270 |
+
"version": "7.7.1",
|
1271 |
+
"resolved": "https://registry.npmjs.org/wavesurfer.js/-/wavesurfer.js-7.7.1.tgz",
|
1272 |
+
"integrity": "sha512-2HFBnTgxtz2e2XMpoPVDxDjxJH6CQLj+Q1TO6U3K2ngtQ4svgymDb4fhK++qTZlL4GTMmUuqxDHEi6wK/8gGtg=="
|
1273 |
+
},
|
1274 |
+
"node_modules/worker-factory": {
|
1275 |
+
"version": "7.0.16",
|
1276 |
+
"resolved": "https://registry.npmjs.org/worker-factory/-/worker-factory-7.0.16.tgz",
|
1277 |
+
"integrity": "sha512-AjDMwO9SwgQhKNgDdL88RidnqP5Sjs3+MH5yu/Es/IuQLlxr3Gcz/fQRqBc85sBijYcsjs2FQD07Vy2vySQUgg==",
|
1278 |
+
"dependencies": {
|
1279 |
+
"@babel/runtime": "^7.23.6",
|
1280 |
+
"compilerr": "^11.0.13",
|
1281 |
+
"fast-unique-numbers": "^8.0.12",
|
1282 |
+
"tslib": "^2.6.2"
|
1283 |
+
}
|
1284 |
+
},
|
1285 |
+
"node_modules/ws": {
|
1286 |
+
"version": "8.16.0",
|
1287 |
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz",
|
1288 |
+
"integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==",
|
1289 |
+
"engines": {
|
1290 |
+
"node": ">=10.0.0"
|
1291 |
+
},
|
1292 |
+
"peerDependencies": {
|
1293 |
+
"bufferutil": "^4.0.1",
|
1294 |
+
"utf-8-validate": ">=5.0.2"
|
1295 |
+
},
|
1296 |
+
"peerDependenciesMeta": {
|
1297 |
+
"bufferutil": {
|
1298 |
+
"optional": true
|
1299 |
+
},
|
1300 |
+
"utf-8-validate": {
|
1301 |
+
"optional": true
|
1302 |
+
}
|
1303 |
+
}
|
1304 |
+
}
|
1305 |
+
}
|
1306 |
+
}
|
src/frontend/package.json
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "gradio_unifiedaudio",
|
3 |
+
"version": "0.4.3",
|
4 |
+
"description": "Gradio UI packages",
|
5 |
+
"type": "module",
|
6 |
+
"author": "",
|
7 |
+
"license": "ISC",
|
8 |
+
"private": false,
|
9 |
+
"dependencies": {
|
10 |
+
"@gradio/atoms": "0.2.1",
|
11 |
+
"@gradio/button": "0.2.3",
|
12 |
+
"@gradio/client": "0.7.2",
|
13 |
+
"@gradio/icons": "0.2.0",
|
14 |
+
"@gradio/statustracker": "0.3.1",
|
15 |
+
"@gradio/upload": "0.3.3",
|
16 |
+
"@gradio/utils": "0.2.0",
|
17 |
+
"@gradio/wasm": "0.2.0",
|
18 |
+
"extendable-media-recorder": "^9.0.0",
|
19 |
+
"extendable-media-recorder-wav-encoder": "^7.0.76",
|
20 |
+
"resize-observer-polyfill": "^1.5.1",
|
21 |
+
"svelte-range-slider-pips": "^2.0.1",
|
22 |
+
"wavesurfer.js": "^7.4.2",
|
23 |
+
"@types/wavesurfer.js": "^6.0.10"
|
24 |
+
},
|
25 |
+
"main_changeset": true,
|
26 |
+
"main": "index.ts",
|
27 |
+
"exports": {
|
28 |
+
".": "./index.ts",
|
29 |
+
"./example": "./Example.svelte",
|
30 |
+
"./package.json": "./package.json"
|
31 |
+
}
|
32 |
+
}
|
src/frontend/player/AudioPlayer.svelte
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { onMount } from "svelte";
|
3 |
+
import { Music } from "@gradio/icons";
|
4 |
+
import type { I18nFormatter } from "@gradio/utils";
|
5 |
+
import WaveSurfer from "wavesurfer.js";
|
6 |
+
import { skipAudio, process_audio } from "../shared/utils";
|
7 |
+
import WaveformControls from "../shared/WaveformControls.svelte";
|
8 |
+
import { Empty } from "@gradio/atoms";
|
9 |
+
import { resolve_wasm_src } from "@gradio/wasm/svelte";
|
10 |
+
import type { FileData } from "@gradio/client";
|
11 |
+
|
12 |
+
export let value: null | FileData = null;
|
13 |
+
export let label: string;
|
14 |
+
export let i18n: I18nFormatter;
|
15 |
+
export let dispatch: (event: any, detail?: any) => void;
|
16 |
+
export let dispatch_blob: (
|
17 |
+
blobs: Uint8Array[] | Blob[],
|
18 |
+
event: "stream" | "change" | "stop_recording"
|
19 |
+
) => Promise<void> = () => Promise.resolve();
|
20 |
+
export let interactive = false;
|
21 |
+
export let waveform_settings = {};
|
22 |
+
export let mode = "";
|
23 |
+
export let handle_reset_value: () => void = () => {};
|
24 |
+
|
25 |
+
let container: HTMLDivElement;
|
26 |
+
let waveform: WaveSurfer;
|
27 |
+
let playing = false;
|
28 |
+
|
29 |
+
let timeRef: HTMLTimeElement;
|
30 |
+
let durationRef: HTMLTimeElement;
|
31 |
+
let audioDuration: number;
|
32 |
+
|
33 |
+
let trimDuration = 0;
|
34 |
+
|
35 |
+
const formatTime = (seconds: number): string => {
|
36 |
+
const minutes = Math.floor(seconds / 60);
|
37 |
+
const secondsRemainder = Math.round(seconds) % 60;
|
38 |
+
const paddedSeconds = `0${secondsRemainder}`.slice(-2);
|
39 |
+
return `${minutes}:${paddedSeconds}`;
|
40 |
+
};
|
41 |
+
|
42 |
+
const create_waveform = (): void => {
|
43 |
+
waveform = WaveSurfer.create({
|
44 |
+
container: container,
|
45 |
+
url: value?.url,
|
46 |
+
...waveform_settings
|
47 |
+
});
|
48 |
+
};
|
49 |
+
|
50 |
+
$: if (container !== undefined) {
|
51 |
+
if (waveform !== undefined) waveform.destroy();
|
52 |
+
container.innerHTML = "";
|
53 |
+
create_waveform();
|
54 |
+
playing = false;
|
55 |
+
}
|
56 |
+
|
57 |
+
$: waveform?.on("decode", (duration: any) => {
|
58 |
+
audioDuration = duration;
|
59 |
+
durationRef && (durationRef.textContent = formatTime(duration));
|
60 |
+
});
|
61 |
+
|
62 |
+
$: waveform?.on(
|
63 |
+
"timeupdate",
|
64 |
+
(currentTime: any) =>
|
65 |
+
timeRef && (timeRef.textContent = formatTime(currentTime))
|
66 |
+
);
|
67 |
+
|
68 |
+
$: waveform?.on("finish", () => {
|
69 |
+
playing = false;
|
70 |
+
dispatch("stop");
|
71 |
+
dispatch("end");
|
72 |
+
});
|
73 |
+
$: waveform?.on("pause", () => {
|
74 |
+
playing = false;
|
75 |
+
dispatch("pause");
|
76 |
+
});
|
77 |
+
$: waveform?.on("play", () => {
|
78 |
+
playing = true;
|
79 |
+
dispatch("play");
|
80 |
+
});
|
81 |
+
|
82 |
+
const handle_trim_audio = async (
|
83 |
+
start: number,
|
84 |
+
end: number
|
85 |
+
): Promise<void> => {
|
86 |
+
mode = "";
|
87 |
+
const decodedData = waveform.getDecodedData();
|
88 |
+
if (decodedData)
|
89 |
+
await process_audio(decodedData, start, end).then(
|
90 |
+
async (trimmedBlob: Uint8Array) => {
|
91 |
+
await dispatch_blob([trimmedBlob], "change");
|
92 |
+
waveform.destroy();
|
93 |
+
create_waveform();
|
94 |
+
}
|
95 |
+
);
|
96 |
+
dispatch("edit");
|
97 |
+
};
|
98 |
+
|
99 |
+
async function load_audio(data: string): Promise<void> {
|
100 |
+
await resolve_wasm_src(data).then((resolved_src) => {
|
101 |
+
if (!resolved_src) return;
|
102 |
+
return waveform?.load(resolved_src);
|
103 |
+
});
|
104 |
+
}
|
105 |
+
|
106 |
+
$: value?.url && load_audio(value.url);
|
107 |
+
|
108 |
+
onMount(() => {
|
109 |
+
window.addEventListener("keydown", (e) => {
|
110 |
+
if (e.key === "ArrowRight" && mode !== "edit") {
|
111 |
+
skipAudio(waveform, 0.1);
|
112 |
+
} else if (e.key === "ArrowLeft" && mode !== "edit") {
|
113 |
+
skipAudio(waveform, -0.1);
|
114 |
+
}
|
115 |
+
});
|
116 |
+
});
|
117 |
+
</script>
|
118 |
+
|
119 |
+
{#if value === null}
|
120 |
+
<Empty size="small">
|
121 |
+
<Music />
|
122 |
+
</Empty>
|
123 |
+
{:else}
|
124 |
+
<div
|
125 |
+
class="component-wrapper"
|
126 |
+
data-testid={label ? "waveform-" + label : "unlabelled-audio"}
|
127 |
+
>
|
128 |
+
<div class="waveform-container">
|
129 |
+
<div id="waveform" bind:this={container} />
|
130 |
+
</div>
|
131 |
+
|
132 |
+
<div class="timestamps">
|
133 |
+
<time bind:this={timeRef} id="time">0:00</time>
|
134 |
+
<div>
|
135 |
+
{#if mode === "edit" && trimDuration > 0}
|
136 |
+
<time id="trim-duration">{formatTime(trimDuration)}</time>
|
137 |
+
{/if}
|
138 |
+
<time bind:this={durationRef} id="duration">0:00</time>
|
139 |
+
</div>
|
140 |
+
</div>
|
141 |
+
|
142 |
+
{#if waveform}
|
143 |
+
<WaveformControls
|
144 |
+
{container}
|
145 |
+
{waveform}
|
146 |
+
{playing}
|
147 |
+
{audioDuration}
|
148 |
+
{i18n}
|
149 |
+
{interactive}
|
150 |
+
{handle_trim_audio}
|
151 |
+
bind:mode
|
152 |
+
bind:trimDuration
|
153 |
+
showRedo={interactive}
|
154 |
+
{handle_reset_value}
|
155 |
+
{waveform_settings}
|
156 |
+
/>
|
157 |
+
{/if}
|
158 |
+
</div>
|
159 |
+
{/if}
|
160 |
+
|
161 |
+
<style>
|
162 |
+
.component-wrapper {
|
163 |
+
padding: var(--size-3);
|
164 |
+
}
|
165 |
+
|
166 |
+
.timestamps {
|
167 |
+
display: flex;
|
168 |
+
justify-content: space-between;
|
169 |
+
align-items: center;
|
170 |
+
width: 100%;
|
171 |
+
padding: var(--size-1) 0;
|
172 |
+
}
|
173 |
+
|
174 |
+
#time {
|
175 |
+
color: var(--neutral-400);
|
176 |
+
}
|
177 |
+
|
178 |
+
#duration {
|
179 |
+
color: var(--neutral-400);
|
180 |
+
}
|
181 |
+
|
182 |
+
#trim-duration {
|
183 |
+
color: var(--color-accent);
|
184 |
+
margin-right: var(--spacing-sm);
|
185 |
+
}
|
186 |
+
.waveform-container {
|
187 |
+
display: flex;
|
188 |
+
align-items: center;
|
189 |
+
justify-content: center;
|
190 |
+
width: var(--size-full);
|
191 |
+
}
|
192 |
+
|
193 |
+
#waveform {
|
194 |
+
width: 100%;
|
195 |
+
height: 100%;
|
196 |
+
position: relative;
|
197 |
+
}
|
198 |
+
</style>
|
src/frontend/pnpm-lock.yaml
ADDED
@@ -0,0 +1,961 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
lockfileVersion: '6.1'
|
2 |
+
|
3 |
+
settings:
|
4 |
+
autoInstallPeers: true
|
5 |
+
excludeLinksFromLockfile: false
|
6 |
+
|
7 |
+
dependencies:
|
8 |
+
'@gradio/atoms':
|
9 |
+
specifier: 0.2.1
|
10 |
+
version: 0.2.1(svelte@4.2.8)
|
11 |
+
'@gradio/button':
|
12 |
+
specifier: 0.2.3
|
13 |
+
version: 0.2.3(svelte@4.2.8)
|
14 |
+
'@gradio/client':
|
15 |
+
specifier: 0.7.2
|
16 |
+
version: 0.7.2
|
17 |
+
'@gradio/icons':
|
18 |
+
specifier: 0.2.0
|
19 |
+
version: 0.2.0
|
20 |
+
'@gradio/statustracker':
|
21 |
+
specifier: 0.3.1
|
22 |
+
version: 0.3.1(svelte@4.2.8)
|
23 |
+
'@gradio/upload':
|
24 |
+
specifier: 0.3.3
|
25 |
+
version: 0.3.3(svelte@4.2.8)
|
26 |
+
'@gradio/utils':
|
27 |
+
specifier: 0.2.0
|
28 |
+
version: 0.2.0(svelte@4.2.8)
|
29 |
+
'@gradio/wasm':
|
30 |
+
specifier: 0.2.0
|
31 |
+
version: 0.2.0
|
32 |
+
'@types/wavesurfer.js':
|
33 |
+
specifier: ^6.0.10
|
34 |
+
version: 6.0.10
|
35 |
+
extendable-media-recorder:
|
36 |
+
specifier: ^9.0.0
|
37 |
+
version: 9.0.0
|
38 |
+
extendable-media-recorder-wav-encoder:
|
39 |
+
specifier: ^7.0.76
|
40 |
+
version: 7.0.76
|
41 |
+
resize-observer-polyfill:
|
42 |
+
specifier: ^1.5.1
|
43 |
+
version: 1.5.1
|
44 |
+
svelte-range-slider-pips:
|
45 |
+
specifier: ^2.0.1
|
46 |
+
version: 2.0.1
|
47 |
+
wavesurfer.js:
|
48 |
+
specifier: ^7.4.2
|
49 |
+
version: 7.4.2
|
50 |
+
|
51 |
+
packages:
|
52 |
+
|
53 |
+
/@ampproject/remapping@2.2.1:
|
54 |
+
resolution: {integrity: sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==}
|
55 |
+
engines: {node: '>=6.0.0'}
|
56 |
+
dependencies:
|
57 |
+
'@jridgewell/gen-mapping': 0.3.3
|
58 |
+
'@jridgewell/trace-mapping': 0.3.21
|
59 |
+
dev: false
|
60 |
+
|
61 |
+
/@babel/runtime@7.23.8:
|
62 |
+
resolution: {integrity: sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==}
|
63 |
+
engines: {node: '>=6.9.0'}
|
64 |
+
dependencies:
|
65 |
+
regenerator-runtime: 0.14.1
|
66 |
+
dev: false
|
67 |
+
|
68 |
+
/@esbuild/aix-ppc64@0.19.11:
|
69 |
+
resolution: {integrity: sha512-FnzU0LyE3ySQk7UntJO4+qIiQgI7KoODnZg5xzXIrFJlKd2P2gwHsHY4927xj9y5PJmJSzULiUCWmv7iWnNa7g==}
|
70 |
+
engines: {node: '>=12'}
|
71 |
+
cpu: [ppc64]
|
72 |
+
os: [aix]
|
73 |
+
requiresBuild: true
|
74 |
+
dev: false
|
75 |
+
optional: true
|
76 |
+
|
77 |
+
/@esbuild/android-arm64@0.19.11:
|
78 |
+
resolution: {integrity: sha512-aiu7K/5JnLj//KOnOfEZ0D90obUkRzDMyqd/wNAUQ34m4YUPVhRZpnqKV9uqDGxT7cToSDnIHsGooyIczu9T+Q==}
|
79 |
+
engines: {node: '>=12'}
|
80 |
+
cpu: [arm64]
|
81 |
+
os: [android]
|
82 |
+
requiresBuild: true
|
83 |
+
dev: false
|
84 |
+
optional: true
|
85 |
+
|
86 |
+
/@esbuild/android-arm@0.19.11:
|
87 |
+
resolution: {integrity: sha512-5OVapq0ClabvKvQ58Bws8+wkLCV+Rxg7tUVbo9xu034Nm536QTII4YzhaFriQ7rMrorfnFKUsArD2lqKbFY4vw==}
|
88 |
+
engines: {node: '>=12'}
|
89 |
+
cpu: [arm]
|
90 |
+
os: [android]
|
91 |
+
requiresBuild: true
|
92 |
+
dev: false
|
93 |
+
optional: true
|
94 |
+
|
95 |
+
/@esbuild/android-x64@0.19.11:
|
96 |
+
resolution: {integrity: sha512-eccxjlfGw43WYoY9QgB82SgGgDbibcqyDTlk3l3C0jOVHKxrjdc9CTwDUQd0vkvYg5um0OH+GpxYvp39r+IPOg==}
|
97 |
+
engines: {node: '>=12'}
|
98 |
+
cpu: [x64]
|
99 |
+
os: [android]
|
100 |
+
requiresBuild: true
|
101 |
+
dev: false
|
102 |
+
optional: true
|
103 |
+
|
104 |
+
/@esbuild/darwin-arm64@0.19.11:
|
105 |
+
resolution: {integrity: sha512-ETp87DRWuSt9KdDVkqSoKoLFHYTrkyz2+65fj9nfXsaV3bMhTCjtQfw3y+um88vGRKRiF7erPrh/ZuIdLUIVxQ==}
|
106 |
+
engines: {node: '>=12'}
|
107 |
+
cpu: [arm64]
|
108 |
+
os: [darwin]
|
109 |
+
requiresBuild: true
|
110 |
+
dev: false
|
111 |
+
optional: true
|
112 |
+
|
113 |
+
/@esbuild/darwin-x64@0.19.11:
|
114 |
+
resolution: {integrity: sha512-fkFUiS6IUK9WYUO/+22omwetaSNl5/A8giXvQlcinLIjVkxwTLSktbF5f/kJMftM2MJp9+fXqZ5ezS7+SALp4g==}
|
115 |
+
engines: {node: '>=12'}
|
116 |
+
cpu: [x64]
|
117 |
+
os: [darwin]
|
118 |
+
requiresBuild: true
|
119 |
+
dev: false
|
120 |
+
optional: true
|
121 |
+
|
122 |
+
/@esbuild/freebsd-arm64@0.19.11:
|
123 |
+
resolution: {integrity: sha512-lhoSp5K6bxKRNdXUtHoNc5HhbXVCS8V0iZmDvyWvYq9S5WSfTIHU2UGjcGt7UeS6iEYp9eeymIl5mJBn0yiuxA==}
|
124 |
+
engines: {node: '>=12'}
|
125 |
+
cpu: [arm64]
|
126 |
+
os: [freebsd]
|
127 |
+
requiresBuild: true
|
128 |
+
dev: false
|
129 |
+
optional: true
|
130 |
+
|
131 |
+
/@esbuild/freebsd-x64@0.19.11:
|
132 |
+
resolution: {integrity: sha512-JkUqn44AffGXitVI6/AbQdoYAq0TEullFdqcMY/PCUZ36xJ9ZJRtQabzMA+Vi7r78+25ZIBosLTOKnUXBSi1Kw==}
|
133 |
+
engines: {node: '>=12'}
|
134 |
+
cpu: [x64]
|
135 |
+
os: [freebsd]
|
136 |
+
requiresBuild: true
|
137 |
+
dev: false
|
138 |
+
optional: true
|
139 |
+
|
140 |
+
/@esbuild/linux-arm64@0.19.11:
|
141 |
+
resolution: {integrity: sha512-LneLg3ypEeveBSMuoa0kwMpCGmpu8XQUh+mL8XXwoYZ6Be2qBnVtcDI5azSvh7vioMDhoJFZzp9GWp9IWpYoUg==}
|
142 |
+
engines: {node: '>=12'}
|
143 |
+
cpu: [arm64]
|
144 |
+
os: [linux]
|
145 |
+
requiresBuild: true
|
146 |
+
dev: false
|
147 |
+
optional: true
|
148 |
+
|
149 |
+
/@esbuild/linux-arm@0.19.11:
|
150 |
+
resolution: {integrity: sha512-3CRkr9+vCV2XJbjwgzjPtO8T0SZUmRZla+UL1jw+XqHZPkPgZiyWvbDvl9rqAN8Zl7qJF0O/9ycMtjU67HN9/Q==}
|
151 |
+
engines: {node: '>=12'}
|
152 |
+
cpu: [arm]
|
153 |
+
os: [linux]
|
154 |
+
requiresBuild: true
|
155 |
+
dev: false
|
156 |
+
optional: true
|
157 |
+
|
158 |
+
/@esbuild/linux-ia32@0.19.11:
|
159 |
+
resolution: {integrity: sha512-caHy++CsD8Bgq2V5CodbJjFPEiDPq8JJmBdeyZ8GWVQMjRD0sU548nNdwPNvKjVpamYYVL40AORekgfIubwHoA==}
|
160 |
+
engines: {node: '>=12'}
|
161 |
+
cpu: [ia32]
|
162 |
+
os: [linux]
|
163 |
+
requiresBuild: true
|
164 |
+
dev: false
|
165 |
+
optional: true
|
166 |
+
|
167 |
+
/@esbuild/linux-loong64@0.19.11:
|
168 |
+
resolution: {integrity: sha512-ppZSSLVpPrwHccvC6nQVZaSHlFsvCQyjnvirnVjbKSHuE5N24Yl8F3UwYUUR1UEPaFObGD2tSvVKbvR+uT1Nrg==}
|
169 |
+
engines: {node: '>=12'}
|
170 |
+
cpu: [loong64]
|
171 |
+
os: [linux]
|
172 |
+
requiresBuild: true
|
173 |
+
dev: false
|
174 |
+
optional: true
|
175 |
+
|
176 |
+
/@esbuild/linux-mips64el@0.19.11:
|
177 |
+
resolution: {integrity: sha512-B5x9j0OgjG+v1dF2DkH34lr+7Gmv0kzX6/V0afF41FkPMMqaQ77pH7CrhWeR22aEeHKaeZVtZ6yFwlxOKPVFyg==}
|
178 |
+
engines: {node: '>=12'}
|
179 |
+
cpu: [mips64el]
|
180 |
+
os: [linux]
|
181 |
+
requiresBuild: true
|
182 |
+
dev: false
|
183 |
+
optional: true
|
184 |
+
|
185 |
+
/@esbuild/linux-ppc64@0.19.11:
|
186 |
+
resolution: {integrity: sha512-MHrZYLeCG8vXblMetWyttkdVRjQlQUb/oMgBNurVEnhj4YWOr4G5lmBfZjHYQHHN0g6yDmCAQRR8MUHldvvRDA==}
|
187 |
+
engines: {node: '>=12'}
|
188 |
+
cpu: [ppc64]
|
189 |
+
os: [linux]
|
190 |
+
requiresBuild: true
|
191 |
+
dev: false
|
192 |
+
optional: true
|
193 |
+
|
194 |
+
/@esbuild/linux-riscv64@0.19.11:
|
195 |
+
resolution: {integrity: sha512-f3DY++t94uVg141dozDu4CCUkYW+09rWtaWfnb3bqe4w5NqmZd6nPVBm+qbz7WaHZCoqXqHz5p6CM6qv3qnSSQ==}
|
196 |
+
engines: {node: '>=12'}
|
197 |
+
cpu: [riscv64]
|
198 |
+
os: [linux]
|
199 |
+
requiresBuild: true
|
200 |
+
dev: false
|
201 |
+
optional: true
|
202 |
+
|
203 |
+
/@esbuild/linux-s390x@0.19.11:
|
204 |
+
resolution: {integrity: sha512-A5xdUoyWJHMMlcSMcPGVLzYzpcY8QP1RtYzX5/bS4dvjBGVxdhuiYyFwp7z74ocV7WDc0n1harxmpq2ePOjI0Q==}
|
205 |
+
engines: {node: '>=12'}
|
206 |
+
cpu: [s390x]
|
207 |
+
os: [linux]
|
208 |
+
requiresBuild: true
|
209 |
+
dev: false
|
210 |
+
optional: true
|
211 |
+
|
212 |
+
/@esbuild/linux-x64@0.19.11:
|
213 |
+
resolution: {integrity: sha512-grbyMlVCvJSfxFQUndw5mCtWs5LO1gUlwP4CDi4iJBbVpZcqLVT29FxgGuBJGSzyOxotFG4LoO5X+M1350zmPA==}
|
214 |
+
engines: {node: '>=12'}
|
215 |
+
cpu: [x64]
|
216 |
+
os: [linux]
|
217 |
+
requiresBuild: true
|
218 |
+
dev: false
|
219 |
+
optional: true
|
220 |
+
|
221 |
+
/@esbuild/netbsd-x64@0.19.11:
|
222 |
+
resolution: {integrity: sha512-13jvrQZJc3P230OhU8xgwUnDeuC/9egsjTkXN49b3GcS5BKvJqZn86aGM8W9pd14Kd+u7HuFBMVtrNGhh6fHEQ==}
|
223 |
+
engines: {node: '>=12'}
|
224 |
+
cpu: [x64]
|
225 |
+
os: [netbsd]
|
226 |
+
requiresBuild: true
|
227 |
+
dev: false
|
228 |
+
optional: true
|
229 |
+
|
230 |
+
/@esbuild/openbsd-x64@0.19.11:
|
231 |
+
resolution: {integrity: sha512-ysyOGZuTp6SNKPE11INDUeFVVQFrhcNDVUgSQVDzqsqX38DjhPEPATpid04LCoUr2WXhQTEZ8ct/EgJCUDpyNw==}
|
232 |
+
engines: {node: '>=12'}
|
233 |
+
cpu: [x64]
|
234 |
+
os: [openbsd]
|
235 |
+
requiresBuild: true
|
236 |
+
dev: false
|
237 |
+
optional: true
|
238 |
+
|
239 |
+
/@esbuild/sunos-x64@0.19.11:
|
240 |
+
resolution: {integrity: sha512-Hf+Sad9nVwvtxy4DXCZQqLpgmRTQqyFyhT3bZ4F2XlJCjxGmRFF0Shwn9rzhOYRB61w9VMXUkxlBy56dk9JJiQ==}
|
241 |
+
engines: {node: '>=12'}
|
242 |
+
cpu: [x64]
|
243 |
+
os: [sunos]
|
244 |
+
requiresBuild: true
|
245 |
+
dev: false
|
246 |
+
optional: true
|
247 |
+
|
248 |
+
/@esbuild/win32-arm64@0.19.11:
|
249 |
+
resolution: {integrity: sha512-0P58Sbi0LctOMOQbpEOvOL44Ne0sqbS0XWHMvvrg6NE5jQ1xguCSSw9jQeUk2lfrXYsKDdOe6K+oZiwKPilYPQ==}
|
250 |
+
engines: {node: '>=12'}
|
251 |
+
cpu: [arm64]
|
252 |
+
os: [win32]
|
253 |
+
requiresBuild: true
|
254 |
+
dev: false
|
255 |
+
optional: true
|
256 |
+
|
257 |
+
/@esbuild/win32-ia32@0.19.11:
|
258 |
+
resolution: {integrity: sha512-6YOrWS+sDJDmshdBIQU+Uoyh7pQKrdykdefC1avn76ss5c+RN6gut3LZA4E2cH5xUEp5/cA0+YxRaVtRAb0xBg==}
|
259 |
+
engines: {node: '>=12'}
|
260 |
+
cpu: [ia32]
|
261 |
+
os: [win32]
|
262 |
+
requiresBuild: true
|
263 |
+
dev: false
|
264 |
+
optional: true
|
265 |
+
|
266 |
+
/@esbuild/win32-x64@0.19.11:
|
267 |
+
resolution: {integrity: sha512-vfkhltrjCAb603XaFhqhAF4LGDi2M4OrCRrFusyQ+iTLQ/o60QQXxc9cZC/FFpihBI9N1Grn6SMKVJ4KP7Fuiw==}
|
268 |
+
engines: {node: '>=12'}
|
269 |
+
cpu: [x64]
|
270 |
+
os: [win32]
|
271 |
+
requiresBuild: true
|
272 |
+
dev: false
|
273 |
+
optional: true
|
274 |
+
|
275 |
+
/@formatjs/ecma402-abstract@1.11.4:
|
276 |
+
resolution: {integrity: sha512-EBikYFp2JCdIfGEb5G9dyCkTGDmC57KSHhRQOC3aYxoPWVZvfWCDjZwkGYHN7Lis/fmuWl906bnNTJifDQ3sXw==}
|
277 |
+
dependencies:
|
278 |
+
'@formatjs/intl-localematcher': 0.2.25
|
279 |
+
tslib: 2.6.2
|
280 |
+
dev: false
|
281 |
+
|
282 |
+
/@formatjs/fast-memoize@1.2.1:
|
283 |
+
resolution: {integrity: sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg==}
|
284 |
+
dependencies:
|
285 |
+
tslib: 2.6.2
|
286 |
+
dev: false
|
287 |
+
|
288 |
+
/@formatjs/icu-messageformat-parser@2.1.0:
|
289 |
+
resolution: {integrity: sha512-Qxv/lmCN6hKpBSss2uQ8IROVnta2r9jd3ymUEIjm2UyIkUCHVcbUVRGL/KS/wv7876edvsPe+hjHVJ4z8YuVaw==}
|
290 |
+
dependencies:
|
291 |
+
'@formatjs/ecma402-abstract': 1.11.4
|
292 |
+
'@formatjs/icu-skeleton-parser': 1.3.6
|
293 |
+
tslib: 2.6.2
|
294 |
+
dev: false
|
295 |
+
|
296 |
+
/@formatjs/icu-skeleton-parser@1.3.6:
|
297 |
+
resolution: {integrity: sha512-I96mOxvml/YLrwU2Txnd4klA7V8fRhb6JG/4hm3VMNmeJo1F03IpV2L3wWt7EweqNLES59SZ4d6hVOPCSf80Bg==}
|
298 |
+
dependencies:
|
299 |
+
'@formatjs/ecma402-abstract': 1.11.4
|
300 |
+
tslib: 2.6.2
|
301 |
+
dev: false
|
302 |
+
|
303 |
+
/@formatjs/intl-localematcher@0.2.25:
|
304 |
+
resolution: {integrity: sha512-YmLcX70BxoSopLFdLr1Ds99NdlTI2oWoLbaUW2M406lxOIPzE1KQhRz2fPUkq34xVZQaihCoU29h0KK7An3bhA==}
|
305 |
+
dependencies:
|
306 |
+
tslib: 2.6.2
|
307 |
+
dev: false
|
308 |
+
|
309 |
+
/@gradio/atoms@0.2.1(svelte@4.2.8):
|
310 |
+
resolution: {integrity: sha512-di3kKSbjxKGngvTAaqUaA6whOVs5BFlQULlWDPq1m37VRgUD7Oq2MkIE+T+YiNAhByN93pqA0hGrWwAUUuxy5Q==}
|
311 |
+
dependencies:
|
312 |
+
'@gradio/icons': 0.2.0
|
313 |
+
'@gradio/utils': 0.2.0(svelte@4.2.8)
|
314 |
+
transitivePeerDependencies:
|
315 |
+
- svelte
|
316 |
+
dev: false
|
317 |
+
|
318 |
+
/@gradio/button@0.2.3(svelte@4.2.8):
|
319 |
+
resolution: {integrity: sha512-vbSMcRNrtBKycnAgpCpepKaC4NNAg36I9qbEaz8wKqHqU02oTOaUeyelEitHLWULqLf3+sy6BM+JxxFjtELgXQ==}
|
320 |
+
dependencies:
|
321 |
+
'@gradio/client': 0.7.2
|
322 |
+
'@gradio/upload': 0.3.3(svelte@4.2.8)
|
323 |
+
'@gradio/utils': 0.2.0(svelte@4.2.8)
|
324 |
+
transitivePeerDependencies:
|
325 |
+
- svelte
|
326 |
+
- utf-8-validate
|
327 |
+
dev: false
|
328 |
+
|
329 |
+
/@gradio/client@0.7.2:
|
330 |
+
resolution: {integrity: sha512-YkT3c0u38ZYPKvOCmT0xLu3Gau4SwMe1Yo0PNvqTLwHfI4++dp5MJIWH97820MUqgQhYy6V3GmVAliHRmnfPbw==}
|
331 |
+
engines: {node: '>=18.0.0'}
|
332 |
+
dependencies:
|
333 |
+
bufferutil: 4.0.8
|
334 |
+
semiver: 1.1.0
|
335 |
+
ws: 8.16.0(bufferutil@4.0.8)
|
336 |
+
transitivePeerDependencies:
|
337 |
+
- utf-8-validate
|
338 |
+
dev: false
|
339 |
+
|
340 |
+
/@gradio/column@0.1.0:
|
341 |
+
resolution: {integrity: sha512-P24nqqVnMXBaDA1f/zSN5HZRho4PxP8Dq+7VltPHlmxIEiZYik2AJ4J0LeuIha34FDO0guu/16evdrpvGIUAfw==}
|
342 |
+
dev: false
|
343 |
+
|
344 |
+
/@gradio/icons@0.2.0:
|
345 |
+
resolution: {integrity: sha512-rfCSmOF+ALqBOjTWL1ICasyA8JuO0MPwFrtlVMyAWp7R14AN8YChC/gbz5fZ0kNBiGGEYOOfqpKxyvC95jGGlg==}
|
346 |
+
dev: false
|
347 |
+
|
348 |
+
/@gradio/statustracker@0.3.1(svelte@4.2.8):
|
349 |
+
resolution: {integrity: sha512-ZpmXZSnbgoFU2J54SrNntwfo2OEuEoRV310Q0zGVTH1VL7loziR7GuYhfIbgS8qFlrWM0MhMoLGDX+k7LAig5w==}
|
350 |
+
dependencies:
|
351 |
+
'@gradio/atoms': 0.2.1(svelte@4.2.8)
|
352 |
+
'@gradio/column': 0.1.0
|
353 |
+
'@gradio/icons': 0.2.0
|
354 |
+
'@gradio/utils': 0.2.0(svelte@4.2.8)
|
355 |
+
transitivePeerDependencies:
|
356 |
+
- svelte
|
357 |
+
dev: false
|
358 |
+
|
359 |
+
/@gradio/theme@0.2.0:
|
360 |
+
resolution: {integrity: sha512-33c68Nk7oRXLn08OxPfjcPm7S4tXGOUV1I1bVgzdM2YV5o1QBOS1GEnXPZPu/CEYPePLMB6bsDwffrLEyLGWVQ==}
|
361 |
+
dev: false
|
362 |
+
|
363 |
+
/@gradio/upload@0.3.3(svelte@4.2.8):
|
364 |
+
resolution: {integrity: sha512-KWRtH9UTe20u1/14KezuZDEwecLZzjDHdSPDUCrk27SrE6ptV8/qLtefOkg9zE+W51iATxDtQAvi0afLQ8XGrw==}
|
365 |
+
dependencies:
|
366 |
+
'@gradio/atoms': 0.2.1(svelte@4.2.8)
|
367 |
+
'@gradio/client': 0.7.2
|
368 |
+
'@gradio/icons': 0.2.0
|
369 |
+
'@gradio/utils': 0.2.0(svelte@4.2.8)
|
370 |
+
transitivePeerDependencies:
|
371 |
+
- svelte
|
372 |
+
- utf-8-validate
|
373 |
+
dev: false
|
374 |
+
|
375 |
+
/@gradio/utils@0.2.0(svelte@4.2.8):
|
376 |
+
resolution: {integrity: sha512-YkwzXufi6IxQrlMW+1sFo8Yn6F9NLL69ZoBsbo7QEhms0v5L7pmOTw+dfd7M3dwbRP2lgjrb52i1kAIN3n6aqQ==}
|
377 |
+
dependencies:
|
378 |
+
'@gradio/theme': 0.2.0
|
379 |
+
svelte-i18n: 3.7.4(svelte@4.2.8)
|
380 |
+
transitivePeerDependencies:
|
381 |
+
- svelte
|
382 |
+
dev: false
|
383 |
+
|
384 |
+
/@gradio/wasm@0.2.0:
|
385 |
+
resolution: {integrity: sha512-lU0Uzn4avbyO4AA1yp7IR2FQcO23YUEU3kn0NA8S9cGIZLzxj1FepPO1TsNXtMymDdKKx72TJW2v4yrv/j3H2A==}
|
386 |
+
dependencies:
|
387 |
+
'@types/path-browserify': 1.0.2
|
388 |
+
path-browserify: 1.0.1
|
389 |
+
dev: false
|
390 |
+
|
391 |
+
/@jridgewell/gen-mapping@0.3.3:
|
392 |
+
resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==}
|
393 |
+
engines: {node: '>=6.0.0'}
|
394 |
+
dependencies:
|
395 |
+
'@jridgewell/set-array': 1.1.2
|
396 |
+
'@jridgewell/sourcemap-codec': 1.4.15
|
397 |
+
'@jridgewell/trace-mapping': 0.3.21
|
398 |
+
dev: false
|
399 |
+
|
400 |
+
/@jridgewell/resolve-uri@3.1.1:
|
401 |
+
resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==}
|
402 |
+
engines: {node: '>=6.0.0'}
|
403 |
+
dev: false
|
404 |
+
|
405 |
+
/@jridgewell/set-array@1.1.2:
|
406 |
+
resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==}
|
407 |
+
engines: {node: '>=6.0.0'}
|
408 |
+
dev: false
|
409 |
+
|
410 |
+
/@jridgewell/sourcemap-codec@1.4.15:
|
411 |
+
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
|
412 |
+
dev: false
|
413 |
+
|
414 |
+
/@jridgewell/trace-mapping@0.3.21:
|
415 |
+
resolution: {integrity: sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g==}
|
416 |
+
dependencies:
|
417 |
+
'@jridgewell/resolve-uri': 3.1.1
|
418 |
+
'@jridgewell/sourcemap-codec': 1.4.15
|
419 |
+
dev: false
|
420 |
+
|
421 |
+
/@types/debounce@1.2.4:
|
422 |
+
resolution: {integrity: sha512-jBqiORIzKDOToaF63Fm//haOCHuwQuLa2202RK4MozpA6lh93eCBc+/8+wZn5OzjJt3ySdc+74SXWXB55Ewtyw==}
|
423 |
+
dev: false
|
424 |
+
|
425 |
+
/@types/estree@1.0.5:
|
426 |
+
resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==}
|
427 |
+
dev: false
|
428 |
+
|
429 |
+
/@types/path-browserify@1.0.2:
|
430 |
+
resolution: {integrity: sha512-ZkC5IUqqIFPXx3ASTTybTzmQdwHwe2C0u3eL75ldQ6T9E9IWFJodn6hIfbZGab73DfyiHN4Xw15gNxUq2FbvBA==}
|
431 |
+
dev: false
|
432 |
+
|
433 |
+
/@types/wavesurfer.js@6.0.10:
|
434 |
+
resolution: {integrity: sha512-LEzDaKM8L/fx8lwh7SQROD8s5MuEtimChhEQ2HwDFJApPmZFALxSwwUMlEj0mT71EstWZuLhijY2uUiNRZtzqg==}
|
435 |
+
dependencies:
|
436 |
+
'@types/debounce': 1.2.4
|
437 |
+
dev: false
|
438 |
+
|
439 |
+
/acorn@8.11.3:
|
440 |
+
resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==}
|
441 |
+
engines: {node: '>=0.4.0'}
|
442 |
+
hasBin: true
|
443 |
+
dev: false
|
444 |
+
|
445 |
+
/aria-query@5.3.0:
|
446 |
+
resolution: {integrity: sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==}
|
447 |
+
dependencies:
|
448 |
+
dequal: 2.0.3
|
449 |
+
dev: false
|
450 |
+
|
451 |
+
/automation-events@6.0.13:
|
452 |
+
resolution: {integrity: sha512-V1D19taPDEB7LUph6FpJv9m2i+UpLR096sAbPKt92sRChCOA6Jt2bcofU/YAwG8F8/qZp3GrrscJ1FzaEHd68w==}
|
453 |
+
engines: {node: '>=16.1.0'}
|
454 |
+
dependencies:
|
455 |
+
'@babel/runtime': 7.23.8
|
456 |
+
tslib: 2.6.2
|
457 |
+
dev: false
|
458 |
+
|
459 |
+
/axobject-query@3.2.1:
|
460 |
+
resolution: {integrity: sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==}
|
461 |
+
dependencies:
|
462 |
+
dequal: 2.0.3
|
463 |
+
dev: false
|
464 |
+
|
465 |
+
/broker-factory@3.0.89:
|
466 |
+
resolution: {integrity: sha512-A2zkxJjpWjItTGzIETq7MFtBD6UgSA1VvfAeJIXsI+gq1nQ0VozuP80iZRXgdwRfFBCDdlB+8rzMO8Bfnwirug==}
|
467 |
+
dependencies:
|
468 |
+
'@babel/runtime': 7.23.8
|
469 |
+
fast-unique-numbers: 8.0.12
|
470 |
+
tslib: 2.6.2
|
471 |
+
worker-factory: 7.0.16
|
472 |
+
dev: false
|
473 |
+
|
474 |
+
/bufferutil@4.0.8:
|
475 |
+
resolution: {integrity: sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==}
|
476 |
+
engines: {node: '>=6.14.2'}
|
477 |
+
requiresBuild: true
|
478 |
+
dependencies:
|
479 |
+
node-gyp-build: 4.8.0
|
480 |
+
dev: false
|
481 |
+
|
482 |
+
/cli-color@2.0.3:
|
483 |
+
resolution: {integrity: sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==}
|
484 |
+
engines: {node: '>=0.10'}
|
485 |
+
dependencies:
|
486 |
+
d: 1.0.1
|
487 |
+
es5-ext: 0.10.62
|
488 |
+
es6-iterator: 2.0.3
|
489 |
+
memoizee: 0.4.15
|
490 |
+
timers-ext: 0.1.7
|
491 |
+
dev: false
|
492 |
+
|
493 |
+
/code-red@1.0.4:
|
494 |
+
resolution: {integrity: sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==}
|
495 |
+
dependencies:
|
496 |
+
'@jridgewell/sourcemap-codec': 1.4.15
|
497 |
+
'@types/estree': 1.0.5
|
498 |
+
acorn: 8.11.3
|
499 |
+
estree-walker: 3.0.3
|
500 |
+
periscopic: 3.1.0
|
501 |
+
dev: false
|
502 |
+
|
503 |
+
/compilerr@11.0.13:
|
504 |
+
resolution: {integrity: sha512-lqq1b3pFfn1Qims/lgzD5+uwOMzrDsUpiZ5LP2v8Sok7K+OFRt+m23GmkTBQl6ONvFSTB+xL1be8GXYsxt5dJQ==}
|
505 |
+
engines: {node: '>=16.1.0'}
|
506 |
+
dependencies:
|
507 |
+
'@babel/runtime': 7.23.8
|
508 |
+
dashify: 2.0.0
|
509 |
+
indefinite-article: 0.0.2
|
510 |
+
tslib: 2.6.2
|
511 |
+
dev: false
|
512 |
+
|
513 |
+
/css-tree@2.3.1:
|
514 |
+
resolution: {integrity: sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==}
|
515 |
+
engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}
|
516 |
+
dependencies:
|
517 |
+
mdn-data: 2.0.30
|
518 |
+
source-map-js: 1.0.2
|
519 |
+
dev: false
|
520 |
+
|
521 |
+
/d@1.0.1:
|
522 |
+
resolution: {integrity: sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==}
|
523 |
+
dependencies:
|
524 |
+
es5-ext: 0.10.62
|
525 |
+
type: 1.2.0
|
526 |
+
dev: false
|
527 |
+
|
528 |
+
/dashify@2.0.0:
|
529 |
+
resolution: {integrity: sha512-hpA5C/YrPjucXypHPPc0oJ1l9Hf6wWbiOL7Ik42cxnsUOhWiCB/fylKbKqqJalW9FgkNQCw16YO8uW9Hs0Iy1A==}
|
530 |
+
engines: {node: '>=4'}
|
531 |
+
dev: false
|
532 |
+
|
533 |
+
/deepmerge@4.3.1:
|
534 |
+
resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==}
|
535 |
+
engines: {node: '>=0.10.0'}
|
536 |
+
dev: false
|
537 |
+
|
538 |
+
/dequal@2.0.3:
|
539 |
+
resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
|
540 |
+
engines: {node: '>=6'}
|
541 |
+
dev: false
|
542 |
+
|
543 |
+
/es5-ext@0.10.62:
|
544 |
+
resolution: {integrity: sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==}
|
545 |
+
engines: {node: '>=0.10'}
|
546 |
+
requiresBuild: true
|
547 |
+
dependencies:
|
548 |
+
es6-iterator: 2.0.3
|
549 |
+
es6-symbol: 3.1.3
|
550 |
+
next-tick: 1.1.0
|
551 |
+
dev: false
|
552 |
+
|
553 |
+
/es6-iterator@2.0.3:
|
554 |
+
resolution: {integrity: sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==}
|
555 |
+
dependencies:
|
556 |
+
d: 1.0.1
|
557 |
+
es5-ext: 0.10.62
|
558 |
+
es6-symbol: 3.1.3
|
559 |
+
dev: false
|
560 |
+
|
561 |
+
/es6-symbol@3.1.3:
|
562 |
+
resolution: {integrity: sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==}
|
563 |
+
dependencies:
|
564 |
+
d: 1.0.1
|
565 |
+
ext: 1.7.0
|
566 |
+
dev: false
|
567 |
+
|
568 |
+
/es6-weak-map@2.0.3:
|
569 |
+
resolution: {integrity: sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==}
|
570 |
+
dependencies:
|
571 |
+
d: 1.0.1
|
572 |
+
es5-ext: 0.10.62
|
573 |
+
es6-iterator: 2.0.3
|
574 |
+
es6-symbol: 3.1.3
|
575 |
+
dev: false
|
576 |
+
|
577 |
+
/esbuild@0.19.11:
|
578 |
+
resolution: {integrity: sha512-HJ96Hev2hX/6i5cDVwcqiJBBtuo9+FeIJOtZ9W1kA5M6AMJRHUZlpYZ1/SbEwtO0ioNAW8rUooVpC/WehY2SfA==}
|
579 |
+
engines: {node: '>=12'}
|
580 |
+
hasBin: true
|
581 |
+
requiresBuild: true
|
582 |
+
optionalDependencies:
|
583 |
+
'@esbuild/aix-ppc64': 0.19.11
|
584 |
+
'@esbuild/android-arm': 0.19.11
|
585 |
+
'@esbuild/android-arm64': 0.19.11
|
586 |
+
'@esbuild/android-x64': 0.19.11
|
587 |
+
'@esbuild/darwin-arm64': 0.19.11
|
588 |
+
'@esbuild/darwin-x64': 0.19.11
|
589 |
+
'@esbuild/freebsd-arm64': 0.19.11
|
590 |
+
'@esbuild/freebsd-x64': 0.19.11
|
591 |
+
'@esbuild/linux-arm': 0.19.11
|
592 |
+
'@esbuild/linux-arm64': 0.19.11
|
593 |
+
'@esbuild/linux-ia32': 0.19.11
|
594 |
+
'@esbuild/linux-loong64': 0.19.11
|
595 |
+
'@esbuild/linux-mips64el': 0.19.11
|
596 |
+
'@esbuild/linux-ppc64': 0.19.11
|
597 |
+
'@esbuild/linux-riscv64': 0.19.11
|
598 |
+
'@esbuild/linux-s390x': 0.19.11
|
599 |
+
'@esbuild/linux-x64': 0.19.11
|
600 |
+
'@esbuild/netbsd-x64': 0.19.11
|
601 |
+
'@esbuild/openbsd-x64': 0.19.11
|
602 |
+
'@esbuild/sunos-x64': 0.19.11
|
603 |
+
'@esbuild/win32-arm64': 0.19.11
|
604 |
+
'@esbuild/win32-ia32': 0.19.11
|
605 |
+
'@esbuild/win32-x64': 0.19.11
|
606 |
+
dev: false
|
607 |
+
|
608 |
+
/estree-walker@2.0.2:
|
609 |
+
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
610 |
+
dev: false
|
611 |
+
|
612 |
+
/estree-walker@3.0.3:
|
613 |
+
resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
|
614 |
+
dependencies:
|
615 |
+
'@types/estree': 1.0.5
|
616 |
+
dev: false
|
617 |
+
|
618 |
+
/event-emitter@0.3.5:
|
619 |
+
resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==}
|
620 |
+
dependencies:
|
621 |
+
d: 1.0.1
|
622 |
+
es5-ext: 0.10.62
|
623 |
+
dev: false
|
624 |
+
|
625 |
+
/ext@1.7.0:
|
626 |
+
resolution: {integrity: sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==}
|
627 |
+
dependencies:
|
628 |
+
type: 2.7.2
|
629 |
+
dev: false
|
630 |
+
|
631 |
+
/extendable-media-recorder-wav-encoder-broker@7.0.93:
|
632 |
+
resolution: {integrity: sha512-mZQlQ9Yyt3/x3vO6apu5hR49RdLCtHVEqjmf3PSi5nPtrQSJKI5n3oUp9v4jRNAJbUCxtRmBZHDZ2HvwHfDtbQ==}
|
633 |
+
dependencies:
|
634 |
+
'@babel/runtime': 7.23.8
|
635 |
+
broker-factory: 3.0.89
|
636 |
+
extendable-media-recorder-wav-encoder-worker: 8.0.90
|
637 |
+
tslib: 2.6.2
|
638 |
+
dev: false
|
639 |
+
|
640 |
+
/extendable-media-recorder-wav-encoder-worker@8.0.90:
|
641 |
+
resolution: {integrity: sha512-13X3svoPjAlOmIWtRSyMC354vZF82GXhQnI2fHwp41k7hQCS1jaQ8WlUMzcyZ2GAKErbuzWAdVuKPLedNpQUDA==}
|
642 |
+
dependencies:
|
643 |
+
'@babel/runtime': 7.23.8
|
644 |
+
tslib: 2.6.2
|
645 |
+
worker-factory: 7.0.16
|
646 |
+
dev: false
|
647 |
+
|
648 |
+
/extendable-media-recorder-wav-encoder@7.0.76:
|
649 |
+
resolution: {integrity: sha512-HLeyR9R0mUPOo7zG3d3GRWltNaSYUjyUZGQ8amRjuQVkZFXszmOIAAUVBq3fou0Z3V1mAEo+mXnCqbEfYtgZXQ==}
|
650 |
+
dependencies:
|
651 |
+
'@babel/runtime': 7.23.8
|
652 |
+
extendable-media-recorder-wav-encoder-broker: 7.0.93
|
653 |
+
extendable-media-recorder-wav-encoder-worker: 8.0.90
|
654 |
+
tslib: 2.6.2
|
655 |
+
dev: false
|
656 |
+
|
657 |
+
/extendable-media-recorder@9.0.0:
|
658 |
+
resolution: {integrity: sha512-50HNf/4wv2V7H7YBXVfxYLnaXQwMVcna9UHZxFPXmgWdThetWNu+TYKwA+xOPWA+rkr8Tqvtldxc/sPC/s/wXg==}
|
659 |
+
dependencies:
|
660 |
+
'@babel/runtime': 7.23.8
|
661 |
+
media-encoder-host: 8.0.104
|
662 |
+
multi-buffer-data-view: 5.0.13
|
663 |
+
recorder-audio-worklet: 6.0.17
|
664 |
+
standardized-audio-context: 25.3.61
|
665 |
+
subscribable-things: 2.1.28
|
666 |
+
tslib: 2.6.2
|
667 |
+
dev: false
|
668 |
+
|
669 |
+
/fast-unique-numbers@8.0.12:
|
670 |
+
resolution: {integrity: sha512-Z4AJueNDnuC/sLxeQqrHP4zgqcBIeQQLbQ0hEx1a7m6Wf7ERrdAyR7CkGfoEFWm9Qla7dpLt0eWPyiO18gqj0A==}
|
671 |
+
engines: {node: '>=16.1.0'}
|
672 |
+
dependencies:
|
673 |
+
'@babel/runtime': 7.23.8
|
674 |
+
tslib: 2.6.2
|
675 |
+
dev: false
|
676 |
+
|
677 |
+
/globalyzer@0.1.0:
|
678 |
+
resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==}
|
679 |
+
dev: false
|
680 |
+
|
681 |
+
/globrex@0.1.2:
|
682 |
+
resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==}
|
683 |
+
dev: false
|
684 |
+
|
685 |
+
/indefinite-article@0.0.2:
|
686 |
+
resolution: {integrity: sha512-Au/2XzRkvxq2J6w5uvSSbBKPZ5kzINx5F2wb0SF8xpRL8BP9Lav81TnRbfPp6p+SYjYxwaaLn4EUwI3/MmYKSw==}
|
687 |
+
dev: false
|
688 |
+
|
689 |
+
/intl-messageformat@9.13.0:
|
690 |
+
resolution: {integrity: sha512-7sGC7QnSQGa5LZP7bXLDhVDtQOeKGeBFGHF2Y8LVBwYZoQZCgWeKoPGTa5GMG8g/TzDgeXuYJQis7Ggiw2xTOw==}
|
691 |
+
dependencies:
|
692 |
+
'@formatjs/ecma402-abstract': 1.11.4
|
693 |
+
'@formatjs/fast-memoize': 1.2.1
|
694 |
+
'@formatjs/icu-messageformat-parser': 2.1.0
|
695 |
+
tslib: 2.6.2
|
696 |
+
dev: false
|
697 |
+
|
698 |
+
/is-promise@2.2.2:
|
699 |
+
resolution: {integrity: sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==}
|
700 |
+
dev: false
|
701 |
+
|
702 |
+
/is-reference@3.0.2:
|
703 |
+
resolution: {integrity: sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==}
|
704 |
+
dependencies:
|
705 |
+
'@types/estree': 1.0.5
|
706 |
+
dev: false
|
707 |
+
|
708 |
+
/locate-character@3.0.0:
|
709 |
+
resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==}
|
710 |
+
dev: false
|
711 |
+
|
712 |
+
/lru-queue@0.1.0:
|
713 |
+
resolution: {integrity: sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==}
|
714 |
+
dependencies:
|
715 |
+
es5-ext: 0.10.62
|
716 |
+
dev: false
|
717 |
+
|
718 |
+
/magic-string@0.30.5:
|
719 |
+
resolution: {integrity: sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==}
|
720 |
+
engines: {node: '>=12'}
|
721 |
+
dependencies:
|
722 |
+
'@jridgewell/sourcemap-codec': 1.4.15
|
723 |
+
dev: false
|
724 |
+
|
725 |
+
/mdn-data@2.0.30:
|
726 |
+
resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==}
|
727 |
+
dev: false
|
728 |
+
|
729 |
+
/media-encoder-host-broker@7.0.94:
|
730 |
+
resolution: {integrity: sha512-M3nBVELYCSaVIQWaClYcnAC5ygCSBnfUCbxkcEhPWg+tYgvMlPwDq7unHS6UZI7uecVwyRTN31IL/wa31x0VEg==}
|
731 |
+
dependencies:
|
732 |
+
'@babel/runtime': 7.23.8
|
733 |
+
broker-factory: 3.0.89
|
734 |
+
fast-unique-numbers: 8.0.12
|
735 |
+
media-encoder-host-worker: 9.1.16
|
736 |
+
tslib: 2.6.2
|
737 |
+
dev: false
|
738 |
+
|
739 |
+
/media-encoder-host-worker@9.1.16:
|
740 |
+
resolution: {integrity: sha512-L1rD1DXoSLxRhgN52cKwNzzqAIo1y+SXSFKzn+Fj5fFNldOCn4wl4BbuPN6u4HW4yHRzxa6mupTjVaKumiw7uw==}
|
741 |
+
dependencies:
|
742 |
+
'@babel/runtime': 7.23.8
|
743 |
+
extendable-media-recorder-wav-encoder-broker: 7.0.93
|
744 |
+
tslib: 2.6.2
|
745 |
+
worker-factory: 7.0.16
|
746 |
+
dev: false
|
747 |
+
|
748 |
+
/media-encoder-host@8.0.104:
|
749 |
+
resolution: {integrity: sha512-DXOm4XbwCKWoCtW2B4leb9YAfC/1HxG8ysT5AOFXNPs5E9UuamDCa0zhtRNPNn2Bp3MJCiB1qo8jORhqVubJhQ==}
|
750 |
+
dependencies:
|
751 |
+
'@babel/runtime': 7.23.8
|
752 |
+
media-encoder-host-broker: 7.0.94
|
753 |
+
media-encoder-host-worker: 9.1.16
|
754 |
+
tslib: 2.6.2
|
755 |
+
dev: false
|
756 |
+
|
757 |
+
/memoizee@0.4.15:
|
758 |
+
resolution: {integrity: sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==}
|
759 |
+
dependencies:
|
760 |
+
d: 1.0.1
|
761 |
+
es5-ext: 0.10.62
|
762 |
+
es6-weak-map: 2.0.3
|
763 |
+
event-emitter: 0.3.5
|
764 |
+
is-promise: 2.2.2
|
765 |
+
lru-queue: 0.1.0
|
766 |
+
next-tick: 1.1.0
|
767 |
+
timers-ext: 0.1.7
|
768 |
+
dev: false
|
769 |
+
|
770 |
+
/mri@1.2.0:
|
771 |
+
resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==}
|
772 |
+
engines: {node: '>=4'}
|
773 |
+
dev: false
|
774 |
+
|
775 |
+
/multi-buffer-data-view@5.0.13:
|
776 |
+
resolution: {integrity: sha512-1aR8uZp6JOEq1tb1euDmCZFm0ksOe8Kub3ItBrDPBKVhlPaknUcAhanDxrSVrJiJb5c+4vsB1U6Tye8AbL9XkQ==}
|
777 |
+
engines: {node: '>=16.1.0'}
|
778 |
+
dependencies:
|
779 |
+
'@babel/runtime': 7.23.8
|
780 |
+
tslib: 2.6.2
|
781 |
+
dev: false
|
782 |
+
|
783 |
+
/next-tick@1.1.0:
|
784 |
+
resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==}
|
785 |
+
dev: false
|
786 |
+
|
787 |
+
/node-gyp-build@4.8.0:
|
788 |
+
resolution: {integrity: sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==}
|
789 |
+
hasBin: true
|
790 |
+
dev: false
|
791 |
+
|
792 |
+
/path-browserify@1.0.1:
|
793 |
+
resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==}
|
794 |
+
dev: false
|
795 |
+
|
796 |
+
/periscopic@3.1.0:
|
797 |
+
resolution: {integrity: sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==}
|
798 |
+
dependencies:
|
799 |
+
'@types/estree': 1.0.5
|
800 |
+
estree-walker: 3.0.3
|
801 |
+
is-reference: 3.0.2
|
802 |
+
dev: false
|
803 |
+
|
804 |
+
/recorder-audio-worklet-processor@5.0.12:
|
805 |
+
resolution: {integrity: sha512-t8PUAo8au5MaxXaofhCCGGYntYm8dJkM4uGz6IQ3VXv29eoLRPAURKUNRCG/rufdwKm21X6LyxulEsWoL+x/EQ==}
|
806 |
+
dependencies:
|
807 |
+
'@babel/runtime': 7.23.8
|
808 |
+
tslib: 2.6.2
|
809 |
+
dev: false
|
810 |
+
|
811 |
+
/recorder-audio-worklet@6.0.17:
|
812 |
+
resolution: {integrity: sha512-SlK6XYwDonSUKUE6OBj+cwZhqzY7Pz3Eiv4dAFfuR5npOHHfj/mvSadmkhk5r6KltZ6aCgXoPNtGYDH6BchXwA==}
|
813 |
+
dependencies:
|
814 |
+
'@babel/runtime': 7.23.8
|
815 |
+
broker-factory: 3.0.89
|
816 |
+
fast-unique-numbers: 8.0.12
|
817 |
+
recorder-audio-worklet-processor: 5.0.12
|
818 |
+
standardized-audio-context: 25.3.61
|
819 |
+
subscribable-things: 2.1.28
|
820 |
+
tslib: 2.6.2
|
821 |
+
worker-factory: 7.0.16
|
822 |
+
dev: false
|
823 |
+
|
824 |
+
/regenerator-runtime@0.14.1:
|
825 |
+
resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==}
|
826 |
+
dev: false
|
827 |
+
|
828 |
+
/resize-observer-polyfill@1.5.1:
|
829 |
+
resolution: {integrity: sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==}
|
830 |
+
dev: false
|
831 |
+
|
832 |
+
/rxjs-interop@2.0.0:
|
833 |
+
resolution: {integrity: sha512-ASEq9atUw7lualXB+knvgtvwkCEvGWV2gDD/8qnASzBkzEARZck9JAyxmY8OS6Nc1pCPEgDTKNcx+YqqYfzArw==}
|
834 |
+
dev: false
|
835 |
+
|
836 |
+
/sade@1.8.1:
|
837 |
+
resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==}
|
838 |
+
engines: {node: '>=6'}
|
839 |
+
dependencies:
|
840 |
+
mri: 1.2.0
|
841 |
+
dev: false
|
842 |
+
|
843 |
+
/semiver@1.1.0:
|
844 |
+
resolution: {integrity: sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==}
|
845 |
+
engines: {node: '>=6'}
|
846 |
+
dev: false
|
847 |
+
|
848 |
+
/source-map-js@1.0.2:
|
849 |
+
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
|
850 |
+
engines: {node: '>=0.10.0'}
|
851 |
+
dev: false
|
852 |
+
|
853 |
+
/standardized-audio-context@25.3.61:
|
854 |
+
resolution: {integrity: sha512-ew5s1DOlSfU/oHtdIbRGhtPriGd2D4ttVY0uB63Ura1bQWG+c0YVFtmy2fBPLcKH5qkIbrHHlwJTikgVsJ62dg==}
|
855 |
+
dependencies:
|
856 |
+
'@babel/runtime': 7.23.8
|
857 |
+
automation-events: 6.0.13
|
858 |
+
tslib: 2.6.2
|
859 |
+
dev: false
|
860 |
+
|
861 |
+
/subscribable-things@2.1.28:
|
862 |
+
resolution: {integrity: sha512-uZipZJ2/EyClGZZSDsRMXBpvDvK18QCKBc42b6fT9TYNFSjwy7+GEWWkxeFY+jCpXhgfrd3CnrQ2reinhFn8yw==}
|
863 |
+
dependencies:
|
864 |
+
'@babel/runtime': 7.23.8
|
865 |
+
rxjs-interop: 2.0.0
|
866 |
+
tslib: 2.6.2
|
867 |
+
dev: false
|
868 |
+
|
869 |
+
/svelte-i18n@3.7.4(svelte@4.2.8):
|
870 |
+
resolution: {integrity: sha512-yGRCNo+eBT4cPuU7IVsYTYjxB7I2V8qgUZPlHnNctJj5IgbJgV78flsRzpjZ/8iUYZrS49oCt7uxlU3AZv/N5Q==}
|
871 |
+
engines: {node: '>= 16'}
|
872 |
+
hasBin: true
|
873 |
+
peerDependencies:
|
874 |
+
svelte: ^3 || ^4
|
875 |
+
dependencies:
|
876 |
+
cli-color: 2.0.3
|
877 |
+
deepmerge: 4.3.1
|
878 |
+
esbuild: 0.19.11
|
879 |
+
estree-walker: 2.0.2
|
880 |
+
intl-messageformat: 9.13.0
|
881 |
+
sade: 1.8.1
|
882 |
+
svelte: 4.2.8
|
883 |
+
tiny-glob: 0.2.9
|
884 |
+
dev: false
|
885 |
+
|
886 |
+
/svelte-range-slider-pips@2.0.1:
|
887 |
+
resolution: {integrity: sha512-sCHvcTgi0ZYE4c/mwSsdALRsfuqEmpwTsSUdL+PUrumZ8u2gv1GKwZ3GohcAcTB6gfmqRBkyn6ujRXrOIga1gw==}
|
888 |
+
dev: false
|
889 |
+
|
890 |
+
/svelte@4.2.8:
|
891 |
+
resolution: {integrity: sha512-hU6dh1MPl8gh6klQZwK/n73GiAHiR95IkFsesLPbMeEZi36ydaXL/ZAb4g9sayT0MXzpxyZjR28yderJHxcmYA==}
|
892 |
+
engines: {node: '>=16'}
|
893 |
+
dependencies:
|
894 |
+
'@ampproject/remapping': 2.2.1
|
895 |
+
'@jridgewell/sourcemap-codec': 1.4.15
|
896 |
+
'@jridgewell/trace-mapping': 0.3.21
|
897 |
+
acorn: 8.11.3
|
898 |
+
aria-query: 5.3.0
|
899 |
+
axobject-query: 3.2.1
|
900 |
+
code-red: 1.0.4
|
901 |
+
css-tree: 2.3.1
|
902 |
+
estree-walker: 3.0.3
|
903 |
+
is-reference: 3.0.2
|
904 |
+
locate-character: 3.0.0
|
905 |
+
magic-string: 0.30.5
|
906 |
+
periscopic: 3.1.0
|
907 |
+
dev: false
|
908 |
+
|
909 |
+
/timers-ext@0.1.7:
|
910 |
+
resolution: {integrity: sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==}
|
911 |
+
dependencies:
|
912 |
+
es5-ext: 0.10.62
|
913 |
+
next-tick: 1.1.0
|
914 |
+
dev: false
|
915 |
+
|
916 |
+
/tiny-glob@0.2.9:
|
917 |
+
resolution: {integrity: sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==}
|
918 |
+
dependencies:
|
919 |
+
globalyzer: 0.1.0
|
920 |
+
globrex: 0.1.2
|
921 |
+
dev: false
|
922 |
+
|
923 |
+
/tslib@2.6.2:
|
924 |
+
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
|
925 |
+
dev: false
|
926 |
+
|
927 |
+
/type@1.2.0:
|
928 |
+
resolution: {integrity: sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==}
|
929 |
+
dev: false
|
930 |
+
|
931 |
+
/type@2.7.2:
|
932 |
+
resolution: {integrity: sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==}
|
933 |
+
dev: false
|
934 |
+
|
935 |
+
/wavesurfer.js@7.4.2:
|
936 |
+
resolution: {integrity: sha512-4pNQ1porOCUBYBmd2F1TqVuBnB2wBPipaw2qI920zYLuPnada0Rd1CURgh8HRuPGKxijj2iyZDFN2UZwsaEuhA==}
|
937 |
+
dev: false
|
938 |
+
|
939 |
+
/worker-factory@7.0.16:
|
940 |
+
resolution: {integrity: sha512-AjDMwO9SwgQhKNgDdL88RidnqP5Sjs3+MH5yu/Es/IuQLlxr3Gcz/fQRqBc85sBijYcsjs2FQD07Vy2vySQUgg==}
|
941 |
+
dependencies:
|
942 |
+
'@babel/runtime': 7.23.8
|
943 |
+
compilerr: 11.0.13
|
944 |
+
fast-unique-numbers: 8.0.12
|
945 |
+
tslib: 2.6.2
|
946 |
+
dev: false
|
947 |
+
|
948 |
+
/ws@8.16.0(bufferutil@4.0.8):
|
949 |
+
resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==}
|
950 |
+
engines: {node: '>=10.0.0'}
|
951 |
+
peerDependencies:
|
952 |
+
bufferutil: ^4.0.1
|
953 |
+
utf-8-validate: '>=5.0.2'
|
954 |
+
peerDependenciesMeta:
|
955 |
+
bufferutil:
|
956 |
+
optional: true
|
957 |
+
utf-8-validate:
|
958 |
+
optional: true
|
959 |
+
dependencies:
|
960 |
+
bufferutil: 4.0.8
|
961 |
+
dev: false
|
src/frontend/recorder/AudioRecorder.svelte
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { onMount } from "svelte";
|
3 |
+
import type { I18nFormatter } from "@gradio/utils";
|
4 |
+
import WaveSurfer from "wavesurfer.js";
|
5 |
+
import { skipAudio, process_audio } from "../shared/utils";
|
6 |
+
import Record from "wavesurfer.js/dist/plugins/record.js";
|
7 |
+
import WaveformControls from "../shared/WaveformControls.svelte";
|
8 |
+
import WaveformRecordControls from "../shared/WaveformRecordControls.svelte";
|
9 |
+
import RecordPlugin from "wavesurfer.js/dist/plugins/record.js";
|
10 |
+
|
11 |
+
export let mode: string;
|
12 |
+
export let i18n: I18nFormatter;
|
13 |
+
export let dispatch: (event: any, detail?: any) => void;
|
14 |
+
export let dispatch_blob: (
|
15 |
+
blobs: Uint8Array[] | Blob[],
|
16 |
+
event: "stream" | "change" | "stop_recording"
|
17 |
+
) => Promise<void> | undefined;
|
18 |
+
export let waveform_settings = {};
|
19 |
+
export let handle_reset_value: () => void;
|
20 |
+
|
21 |
+
let micWaveform: WaveSurfer;
|
22 |
+
let recordingWaveform: WaveSurfer;
|
23 |
+
let playing = false;
|
24 |
+
let container: HTMLDivElement;
|
25 |
+
|
26 |
+
let record: Record;
|
27 |
+
let recordedAudio: string | null = null;
|
28 |
+
|
29 |
+
// timestamps
|
30 |
+
let timeRef: HTMLTimeElement;
|
31 |
+
let durationRef: HTMLTimeElement;
|
32 |
+
let audioDuration: number;
|
33 |
+
let seconds = 0;
|
34 |
+
let interval: NodeJS.Timeout;
|
35 |
+
let timing = false;
|
36 |
+
// trimming
|
37 |
+
let trimDuration = 0;
|
38 |
+
|
39 |
+
const start_interval = (): void => {
|
40 |
+
clearInterval(interval);
|
41 |
+
interval = setInterval(() => {
|
42 |
+
seconds++;
|
43 |
+
}, 1000);
|
44 |
+
};
|
45 |
+
|
46 |
+
const format_time = (seconds: number): string => {
|
47 |
+
const minutes = Math.floor(seconds / 60);
|
48 |
+
const secondsRemainder = Math.round(seconds) % 60;
|
49 |
+
const paddedSeconds = `0${secondsRemainder}`.slice(-2);
|
50 |
+
return `${minutes}:${paddedSeconds}`;
|
51 |
+
};
|
52 |
+
|
53 |
+
$: record?.on("record-start", () => {
|
54 |
+
start_interval();
|
55 |
+
timing = true;
|
56 |
+
dispatch("start_recording");
|
57 |
+
});
|
58 |
+
|
59 |
+
$: record?.on("record-end", async (blob) => {
|
60 |
+
seconds = 0;
|
61 |
+
timing = false;
|
62 |
+
clearInterval(interval);
|
63 |
+
const array_buffer = await blob.arrayBuffer();
|
64 |
+
const context = new AudioContext();
|
65 |
+
const audio_buffer = await context.decodeAudioData(array_buffer);
|
66 |
+
|
67 |
+
if (audio_buffer)
|
68 |
+
await process_audio(audio_buffer).then(
|
69 |
+
async (trimmedBlob: Uint8Array) => {
|
70 |
+
await dispatch_blob([trimmedBlob], "change");
|
71 |
+
await dispatch_blob([trimmedBlob], "stop_recording");
|
72 |
+
}
|
73 |
+
);
|
74 |
+
});
|
75 |
+
|
76 |
+
$: record?.on("record-pause", () => {
|
77 |
+
dispatch("pause_recording");
|
78 |
+
clearInterval(interval);
|
79 |
+
});
|
80 |
+
|
81 |
+
$: record?.on("record-resume", () => {
|
82 |
+
start_interval();
|
83 |
+
});
|
84 |
+
|
85 |
+
$: recordingWaveform?.on("decode", (duration: any) => {
|
86 |
+
audioDuration = duration;
|
87 |
+
durationRef && (durationRef.textContent = format_time(duration));
|
88 |
+
});
|
89 |
+
|
90 |
+
$: recordingWaveform?.on(
|
91 |
+
"timeupdate",
|
92 |
+
(currentTime: any) =>
|
93 |
+
timeRef && (timeRef.textContent = format_time(currentTime))
|
94 |
+
);
|
95 |
+
|
96 |
+
$: recordingWaveform?.on("pause", () => {
|
97 |
+
dispatch("pause");
|
98 |
+
playing = false;
|
99 |
+
});
|
100 |
+
|
101 |
+
$: recordingWaveform?.on("play", () => {
|
102 |
+
dispatch("play");
|
103 |
+
playing = true;
|
104 |
+
});
|
105 |
+
|
106 |
+
$: recordingWaveform?.on("finish", () => {
|
107 |
+
dispatch("stop");
|
108 |
+
dispatch("end");
|
109 |
+
playing = false;
|
110 |
+
});
|
111 |
+
|
112 |
+
const create_mic_waveform = (): void => {
|
113 |
+
const recorder = document.getElementById("microphone");
|
114 |
+
if (recorder) recorder.innerHTML = "";
|
115 |
+
if (micWaveform !== undefined) micWaveform.destroy();
|
116 |
+
if (!recorder) return;
|
117 |
+
micWaveform = WaveSurfer.create({
|
118 |
+
...waveform_settings,
|
119 |
+
container: recorder
|
120 |
+
});
|
121 |
+
|
122 |
+
record = micWaveform.registerPlugin(RecordPlugin.create());
|
123 |
+
record.startMic();
|
124 |
+
};
|
125 |
+
|
126 |
+
const create_recording_waveform = (): void => {
|
127 |
+
let recording = document.getElementById("recording");
|
128 |
+
if (!recordedAudio || !recording) return;
|
129 |
+
recordingWaveform = WaveSurfer.create({
|
130 |
+
container: recording,
|
131 |
+
url: recordedAudio,
|
132 |
+
...waveform_settings
|
133 |
+
});
|
134 |
+
};
|
135 |
+
|
136 |
+
$: record?.on("record-end", (blob) => {
|
137 |
+
recordedAudio = URL.createObjectURL(blob);
|
138 |
+
|
139 |
+
const microphone = document.getElementById("microphone");
|
140 |
+
const recording = document.getElementById("recording");
|
141 |
+
|
142 |
+
if (microphone) microphone.style.display = "none";
|
143 |
+
if (recording && recordedAudio) {
|
144 |
+
recording.innerHTML = "";
|
145 |
+
create_recording_waveform();
|
146 |
+
}
|
147 |
+
});
|
148 |
+
|
149 |
+
const handle_trim_audio = async (
|
150 |
+
start: number,
|
151 |
+
end: number
|
152 |
+
): Promise<void> => {
|
153 |
+
mode = "edit";
|
154 |
+
const decodedData = recordingWaveform.getDecodedData();
|
155 |
+
if (decodedData)
|
156 |
+
await process_audio(decodedData, start, end).then(
|
157 |
+
async (trimmedAudio: Uint8Array) => {
|
158 |
+
await dispatch_blob([trimmedAudio], "change");
|
159 |
+
recordingWaveform.destroy();
|
160 |
+
create_recording_waveform();
|
161 |
+
}
|
162 |
+
);
|
163 |
+
dispatch("edit");
|
164 |
+
};
|
165 |
+
|
166 |
+
onMount(() => {
|
167 |
+
create_mic_waveform();
|
168 |
+
|
169 |
+
window.addEventListener("keydown", (e) => {
|
170 |
+
if (e.key === "ArrowRight") {
|
171 |
+
skipAudio(recordingWaveform, 0.1);
|
172 |
+
} else if (e.key === "ArrowLeft") {
|
173 |
+
skipAudio(recordingWaveform, -0.1);
|
174 |
+
}
|
175 |
+
});
|
176 |
+
});
|
177 |
+
</script>
|
178 |
+
|
179 |
+
<div class="component-wrapper">
|
180 |
+
<div id="microphone" data-testid="microphone-waveform" />
|
181 |
+
|
182 |
+
{#if micWaveform && !recordedAudio}
|
183 |
+
<WaveformRecordControls bind:record {dispatch} />
|
184 |
+
{/if}
|
185 |
+
|
186 |
+
{#if recordingWaveform && recordedAudio}
|
187 |
+
<WaveformControls
|
188 |
+
bind:waveform={recordingWaveform}
|
189 |
+
{container}
|
190 |
+
{playing}
|
191 |
+
{audioDuration}
|
192 |
+
{i18n}
|
193 |
+
interactive={true}
|
194 |
+
{handle_trim_audio}
|
195 |
+
bind:trimDuration
|
196 |
+
bind:mode
|
197 |
+
showRedo
|
198 |
+
{handle_reset_value}
|
199 |
+
{waveform_settings}
|
200 |
+
/>
|
201 |
+
{/if}
|
202 |
+
</div>
|
203 |
+
|
204 |
+
<style>
|
205 |
+
#microphone {
|
206 |
+
width: 100%;
|
207 |
+
display: none;
|
208 |
+
}
|
209 |
+
|
210 |
+
.component-wrapper {
|
211 |
+
padding: var(--size-3);
|
212 |
+
}
|
213 |
+
</style>
|
src/frontend/shared/WaveformControls.svelte
ADDED
@@ -0,0 +1,342 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { Play, Pause, Forward, Backward, Undo, Trim } from "@gradio/icons";
|
3 |
+
import { getSkipRewindAmount } from "../shared/utils";
|
4 |
+
import type { I18nFormatter } from "@gradio/utils";
|
5 |
+
import WaveSurfer from "wavesurfer.js";
|
6 |
+
import RegionsPlugin, {
|
7 |
+
type Region
|
8 |
+
} from "wavesurfer.js/dist/plugins/regions.js";
|
9 |
+
import type { WaveformOptions } from "./types";
|
10 |
+
|
11 |
+
export let waveform: WaveSurfer;
|
12 |
+
export let audioDuration: number;
|
13 |
+
export let i18n: I18nFormatter;
|
14 |
+
export let playing: boolean;
|
15 |
+
export let showRedo = false;
|
16 |
+
export let interactive = false;
|
17 |
+
export let handle_trim_audio: (start: number, end: number) => void;
|
18 |
+
export let mode = "";
|
19 |
+
export let container: HTMLDivElement;
|
20 |
+
export let handle_reset_value: () => void;
|
21 |
+
export let waveform_settings: WaveformOptions = {};
|
22 |
+
|
23 |
+
export let trimDuration = 0;
|
24 |
+
|
25 |
+
let playbackSpeeds = [0.5, 1, 1.5, 2];
|
26 |
+
let playbackSpeed = playbackSpeeds[1];
|
27 |
+
|
28 |
+
let trimRegion: RegionsPlugin;
|
29 |
+
let activeRegion: Region | null = null;
|
30 |
+
|
31 |
+
let leftRegionHandle: HTMLDivElement | null;
|
32 |
+
let rightRegionHandle: HTMLDivElement | null;
|
33 |
+
let activeHandle = "";
|
34 |
+
|
35 |
+
$: trimRegion = waveform.registerPlugin(RegionsPlugin.create());
|
36 |
+
|
37 |
+
$: trimRegion?.on("region-out", (region) => {
|
38 |
+
region.play();
|
39 |
+
});
|
40 |
+
|
41 |
+
$: trimRegion?.on("region-updated", (region) => {
|
42 |
+
trimDuration = region.end - region.start;
|
43 |
+
});
|
44 |
+
|
45 |
+
$: trimRegion?.on("region-clicked", (region, e) => {
|
46 |
+
e.stopPropagation(); // prevent triggering a click on the waveform
|
47 |
+
activeRegion = region;
|
48 |
+
region.play();
|
49 |
+
});
|
50 |
+
|
51 |
+
const addTrimRegion = (): void => {
|
52 |
+
activeRegion = trimRegion.addRegion({
|
53 |
+
start: audioDuration / 4,
|
54 |
+
end: audioDuration / 2,
|
55 |
+
color: "hsla(15, 85%, 40%, 0.4)",
|
56 |
+
drag: true,
|
57 |
+
resize: true
|
58 |
+
});
|
59 |
+
|
60 |
+
trimDuration = activeRegion.end - activeRegion.start;
|
61 |
+
};
|
62 |
+
|
63 |
+
$: if (activeRegion) {
|
64 |
+
const shadowRoot = container.children[0]!.shadowRoot!;
|
65 |
+
|
66 |
+
rightRegionHandle = shadowRoot.querySelector('[data-resize="right"]');
|
67 |
+
leftRegionHandle = shadowRoot.querySelector('[data-resize="left"]');
|
68 |
+
|
69 |
+
if (leftRegionHandle && rightRegionHandle) {
|
70 |
+
leftRegionHandle.setAttribute("role", "button");
|
71 |
+
rightRegionHandle.setAttribute("role", "button");
|
72 |
+
leftRegionHandle?.setAttribute("aria-label", "Drag to adjust start time");
|
73 |
+
rightRegionHandle?.setAttribute("aria-label", "Drag to adjust end time");
|
74 |
+
leftRegionHandle?.setAttribute("tabindex", "0");
|
75 |
+
rightRegionHandle?.setAttribute("tabindex", "0");
|
76 |
+
|
77 |
+
leftRegionHandle.addEventListener("focus", () => {
|
78 |
+
if (trimRegion) activeHandle = "left";
|
79 |
+
});
|
80 |
+
|
81 |
+
rightRegionHandle.addEventListener("focus", () => {
|
82 |
+
if (trimRegion) activeHandle = "right";
|
83 |
+
});
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
const trimAudio = (): void => {
|
88 |
+
if (waveform && trimRegion) {
|
89 |
+
if (activeRegion) {
|
90 |
+
const start = activeRegion.start;
|
91 |
+
const end = activeRegion.end;
|
92 |
+
handle_trim_audio(start, end);
|
93 |
+
mode = "";
|
94 |
+
activeRegion = null;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
};
|
98 |
+
|
99 |
+
const clearRegions = (): void => {
|
100 |
+
trimRegion?.getRegions().forEach((region) => {
|
101 |
+
region.remove();
|
102 |
+
});
|
103 |
+
trimRegion?.clearRegions();
|
104 |
+
};
|
105 |
+
|
106 |
+
const toggleTrimmingMode = (): void => {
|
107 |
+
clearRegions();
|
108 |
+
if (mode === "edit") {
|
109 |
+
mode = "";
|
110 |
+
} else {
|
111 |
+
mode = "edit";
|
112 |
+
addTrimRegion();
|
113 |
+
}
|
114 |
+
};
|
115 |
+
|
116 |
+
const adjustRegionHandles = (handle: string, key: string): void => {
|
117 |
+
let newStart;
|
118 |
+
let newEnd;
|
119 |
+
|
120 |
+
if (!activeRegion) return;
|
121 |
+
if (handle === "left") {
|
122 |
+
if (key === "ArrowLeft") {
|
123 |
+
newStart = activeRegion.start - 0.05;
|
124 |
+
newEnd = activeRegion.end;
|
125 |
+
} else {
|
126 |
+
newStart = activeRegion.start + 0.05;
|
127 |
+
newEnd = activeRegion.end;
|
128 |
+
}
|
129 |
+
} else {
|
130 |
+
if (key === "ArrowLeft") {
|
131 |
+
newStart = activeRegion.start;
|
132 |
+
newEnd = activeRegion.end - 0.05;
|
133 |
+
} else {
|
134 |
+
newStart = activeRegion.start;
|
135 |
+
newEnd = activeRegion.end + 0.05;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
activeRegion.setOptions({
|
140 |
+
start: newStart,
|
141 |
+
end: newEnd
|
142 |
+
});
|
143 |
+
|
144 |
+
trimDuration = activeRegion.end - activeRegion.start;
|
145 |
+
};
|
146 |
+
|
147 |
+
$: trimRegion &&
|
148 |
+
window.addEventListener("keydown", (e) => {
|
149 |
+
if (e.key === "ArrowLeft") {
|
150 |
+
adjustRegionHandles(activeHandle, "ArrowLeft");
|
151 |
+
} else if (e.key === "ArrowRight") {
|
152 |
+
adjustRegionHandles(activeHandle, "ArrowRight");
|
153 |
+
}
|
154 |
+
});
|
155 |
+
</script>
|
156 |
+
|
157 |
+
<div class="controls" data-testid="waveform-controls">
|
158 |
+
<button
|
159 |
+
class="playback icon"
|
160 |
+
aria-label={`Adjust playback speed to ${
|
161 |
+
playbackSpeeds[
|
162 |
+
(playbackSpeeds.indexOf(playbackSpeed) + 1) % playbackSpeeds.length
|
163 |
+
]
|
164 |
+
}x`}
|
165 |
+
on:click={() => {
|
166 |
+
playbackSpeed =
|
167 |
+
playbackSpeeds[
|
168 |
+
(playbackSpeeds.indexOf(playbackSpeed) + 1) % playbackSpeeds.length
|
169 |
+
];
|
170 |
+
|
171 |
+
waveform.setPlaybackRate(playbackSpeed);
|
172 |
+
}}
|
173 |
+
>
|
174 |
+
<span>{playbackSpeed}x</span>
|
175 |
+
</button>
|
176 |
+
|
177 |
+
<div class="play-pause-wrapper">
|
178 |
+
<button
|
179 |
+
class="rewind icon"
|
180 |
+
aria-label={`Skip backwards by ${getSkipRewindAmount(
|
181 |
+
audioDuration,
|
182 |
+
waveform_settings.skip_length
|
183 |
+
)} seconds`}
|
184 |
+
on:click={() =>
|
185 |
+
waveform.skip(
|
186 |
+
getSkipRewindAmount(audioDuration, waveform_settings.skip_length) * -1
|
187 |
+
)}
|
188 |
+
>
|
189 |
+
<Backward />
|
190 |
+
</button>
|
191 |
+
<button
|
192 |
+
class="play-pause-button icon"
|
193 |
+
on:click={() => waveform.playPause()}
|
194 |
+
aria-label={playing ? i18n("common.play") : i18n("common.pause")}
|
195 |
+
>
|
196 |
+
{#if playing}
|
197 |
+
<Pause />
|
198 |
+
{:else}
|
199 |
+
<Play />
|
200 |
+
{/if}
|
201 |
+
</button>
|
202 |
+
<button
|
203 |
+
class="skip icon"
|
204 |
+
aria-label="Skip forward by {getSkipRewindAmount(
|
205 |
+
audioDuration,
|
206 |
+
waveform_settings.skip_length
|
207 |
+
)} seconds"
|
208 |
+
on:click={() =>
|
209 |
+
waveform.skip(
|
210 |
+
getSkipRewindAmount(audioDuration, waveform_settings.skip_length)
|
211 |
+
)}
|
212 |
+
>
|
213 |
+
<Forward />
|
214 |
+
</button>
|
215 |
+
</div>
|
216 |
+
|
217 |
+
<div class="settings-wrapper">
|
218 |
+
{#if showRedo && mode === ""}
|
219 |
+
<button
|
220 |
+
class="action icon"
|
221 |
+
aria-label="Reset audio"
|
222 |
+
on:click={() => {
|
223 |
+
handle_reset_value();
|
224 |
+
clearRegions();
|
225 |
+
mode = "";
|
226 |
+
}}
|
227 |
+
>
|
228 |
+
<Undo />
|
229 |
+
</button>
|
230 |
+
{/if}
|
231 |
+
|
232 |
+
{#if interactive}
|
233 |
+
{#if mode === ""}
|
234 |
+
<button
|
235 |
+
class="action icon"
|
236 |
+
aria-label="Trim audio to selection"
|
237 |
+
on:click={toggleTrimmingMode}
|
238 |
+
>
|
239 |
+
<Trim />
|
240 |
+
</button>
|
241 |
+
{:else}
|
242 |
+
<button class="text-button" on:click={trimAudio}>Trim</button>
|
243 |
+
<button class="text-button" on:click={toggleTrimmingMode}>Cancel</button
|
244 |
+
>
|
245 |
+
{/if}
|
246 |
+
{/if}
|
247 |
+
</div>
|
248 |
+
</div>
|
249 |
+
|
250 |
+
<style>
|
251 |
+
.settings-wrapper {
|
252 |
+
display: flex;
|
253 |
+
justify-self: self-end;
|
254 |
+
}
|
255 |
+
.text-button {
|
256 |
+
border: 1px solid var(--neutral-400);
|
257 |
+
border-radius: var(--radius-sm);
|
258 |
+
font-weight: 300;
|
259 |
+
font-size: var(--size-3);
|
260 |
+
text-align: center;
|
261 |
+
color: var(--neutral-400);
|
262 |
+
height: var(--size-5);
|
263 |
+
font-weight: bold;
|
264 |
+
padding: 0 5px;
|
265 |
+
margin-left: 5px;
|
266 |
+
}
|
267 |
+
|
268 |
+
.text-button:hover,
|
269 |
+
.text-button:focus {
|
270 |
+
color: var(--color-accent);
|
271 |
+
border-color: var(--color-accent);
|
272 |
+
}
|
273 |
+
|
274 |
+
.controls {
|
275 |
+
display: grid;
|
276 |
+
grid-template-columns: 1fr 1fr 1fr;
|
277 |
+
margin-top: 5px;
|
278 |
+
overflow: hidden;
|
279 |
+
align-items: center;
|
280 |
+
}
|
281 |
+
|
282 |
+
@media (max-width: 320px) {
|
283 |
+
.controls {
|
284 |
+
display: flex;
|
285 |
+
flex-wrap: wrap;
|
286 |
+
}
|
287 |
+
|
288 |
+
.controls * {
|
289 |
+
margin: var(--spacing-sm);
|
290 |
+
}
|
291 |
+
|
292 |
+
.controls .text-button {
|
293 |
+
margin-left: 0;
|
294 |
+
}
|
295 |
+
}
|
296 |
+
.action {
|
297 |
+
width: var(--size-5);
|
298 |
+
width: var(--size-5);
|
299 |
+
color: var(--neutral-400);
|
300 |
+
margin-left: var(--spacing-md);
|
301 |
+
}
|
302 |
+
.icon:hover,
|
303 |
+
.icon:focus {
|
304 |
+
color: var(--color-accent);
|
305 |
+
}
|
306 |
+
.play-pause-wrapper {
|
307 |
+
display: flex;
|
308 |
+
justify-self: center;
|
309 |
+
}
|
310 |
+
.playback {
|
311 |
+
border: 1px solid var(--neutral-400);
|
312 |
+
border-radius: var(--radius-sm);
|
313 |
+
width: 5.5ch;
|
314 |
+
font-weight: 300;
|
315 |
+
font-size: var(--size-3);
|
316 |
+
text-align: center;
|
317 |
+
color: var(--neutral-400);
|
318 |
+
height: var(--size-5);
|
319 |
+
font-weight: bold;
|
320 |
+
}
|
321 |
+
|
322 |
+
.playback:hover {
|
323 |
+
color: var(--color-accent);
|
324 |
+
border-color: var(--color-accent);
|
325 |
+
}
|
326 |
+
|
327 |
+
.rewind,
|
328 |
+
.skip {
|
329 |
+
margin: 0 10px;
|
330 |
+
color: var(--neutral-400);
|
331 |
+
}
|
332 |
+
|
333 |
+
.play-pause-button {
|
334 |
+
width: var(--size-8);
|
335 |
+
width: var(--size-8);
|
336 |
+
display: flex;
|
337 |
+
align-items: center;
|
338 |
+
justify-content: center;
|
339 |
+
color: var(--neutral-400);
|
340 |
+
fill: var(--neutral-400);
|
341 |
+
}
|
342 |
+
</style>
|
src/frontend/shared/WaveformRecordControls.svelte
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { onMount } from "svelte";
|
3 |
+
import RecordPlugin from "wavesurfer.js/dist/plugins/record.js";
|
4 |
+
|
5 |
+
export let record: RecordPlugin;
|
6 |
+
export let dispatch: (event: string, detail?: any) => void;
|
7 |
+
|
8 |
+
let recordButton: HTMLButtonElement;
|
9 |
+
let stopButton: HTMLButtonElement;
|
10 |
+
|
11 |
+
onMount(() => {
|
12 |
+
recordButton = document.getElementById("record") as HTMLButtonElement;
|
13 |
+
stopButton = document.getElementById("stop") as HTMLButtonElement;
|
14 |
+
});
|
15 |
+
|
16 |
+
function record_click() {
|
17 |
+
if (isRecording) {
|
18 |
+
record.stopRecording();
|
19 |
+
dispatch("stop_recording");
|
20 |
+
} else {
|
21 |
+
record.startRecording();
|
22 |
+
dispatch("start_recording");
|
23 |
+
}
|
24 |
+
isRecording = !isRecording;
|
25 |
+
}
|
26 |
+
|
27 |
+
let isRecording = false;
|
28 |
+
</script>
|
29 |
+
|
30 |
+
<div class="wrapper">
|
31 |
+
{#if !isRecording}
|
32 |
+
<button
|
33 |
+
bind:this={recordButton}
|
34 |
+
class="record-button"
|
35 |
+
on:click={record_click}
|
36 |
+
>
|
37 |
+
<div class="microphone-icon">
|
38 |
+
<img
|
39 |
+
width="200"
|
40 |
+
height="200"
|
41 |
+
src="https://img.icons8.com/material-rounded/200/microphone.png"
|
42 |
+
alt="microphone"
|
43 |
+
/>
|
44 |
+
</div>
|
45 |
+
</button>
|
46 |
+
{:else}
|
47 |
+
<button
|
48 |
+
bind:this={stopButton}
|
49 |
+
class="stop-button"
|
50 |
+
on:click={record_click}
|
51 |
+
>
|
52 |
+
<div class="stop-icon pulsate">
|
53 |
+
<img
|
54 |
+
width="200"
|
55 |
+
height="200"
|
56 |
+
src="https://img.icons8.com/material-rounded/200/stop.png"
|
57 |
+
alt="stop"
|
58 |
+
/>
|
59 |
+
</div>
|
60 |
+
</button>
|
61 |
+
{/if}
|
62 |
+
</div>
|
63 |
+
|
64 |
+
<style>
|
65 |
+
.wrapper {
|
66 |
+
display: flex;
|
67 |
+
align-items: center;
|
68 |
+
justify-content: center;
|
69 |
+
align-items: center;
|
70 |
+
border-radius: 50px;
|
71 |
+
}
|
72 |
+
|
73 |
+
.microphone-icon {
|
74 |
+
display: flex;
|
75 |
+
align-items: center;
|
76 |
+
justify-content: center;
|
77 |
+
height: 100%;
|
78 |
+
}
|
79 |
+
|
80 |
+
.stop-icon {
|
81 |
+
display: flex;
|
82 |
+
align-items: center;
|
83 |
+
justify-content: center;
|
84 |
+
height: 100%;
|
85 |
+
}
|
86 |
+
|
87 |
+
.record-button {
|
88 |
+
height: 350px;
|
89 |
+
width: 350px;
|
90 |
+
border-radius: 50%;
|
91 |
+
display: flex;
|
92 |
+
align-items: center;
|
93 |
+
justify-content: center;
|
94 |
+
background: white;
|
95 |
+
border: 6px solid rgb(0, 140, 255);
|
96 |
+
}
|
97 |
+
|
98 |
+
.stop-button {
|
99 |
+
height: 350px;
|
100 |
+
width: 350px;
|
101 |
+
border-radius: 50%;
|
102 |
+
display: flex;
|
103 |
+
align-items: center;
|
104 |
+
justify-content: center;
|
105 |
+
background: white;
|
106 |
+
border: 6px solid red;
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
@keyframes pulsate {
|
111 |
+
0% {
|
112 |
+
transform: scale(1);
|
113 |
+
}
|
114 |
+
50% {
|
115 |
+
transform: scale(1.1);
|
116 |
+
}
|
117 |
+
100% {
|
118 |
+
transform: scale(1);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
.pulsate {
|
123 |
+
animation: pulsate 1s infinite;
|
124 |
+
}
|
125 |
+
|
126 |
+
.record-button:disabled {
|
127 |
+
cursor: not-allowed;
|
128 |
+
opacity: 0.5;
|
129 |
+
}
|
130 |
+
|
131 |
+
@keyframes scaling {
|
132 |
+
0% {
|
133 |
+
background-color: var(--primary-600);
|
134 |
+
scale: 1;
|
135 |
+
}
|
136 |
+
50% {
|
137 |
+
background-color: var(--primary-600);
|
138 |
+
scale: 1.2;
|
139 |
+
}
|
140 |
+
100% {
|
141 |
+
background-color: var(--primary-600);
|
142 |
+
scale: 1;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
</style>
|
src/frontend/shared/audioBufferToWav.ts
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export function audioBufferToWav(audioBuffer: AudioBuffer): Uint8Array {
|
2 |
+
const numOfChan = audioBuffer.numberOfChannels;
|
3 |
+
const length = audioBuffer.length * numOfChan * 2 + 44;
|
4 |
+
const buffer = new ArrayBuffer(length);
|
5 |
+
const view = new DataView(buffer);
|
6 |
+
let offset = 0;
|
7 |
+
|
8 |
+
// Write WAV header
|
9 |
+
const writeString = function (
|
10 |
+
view: DataView,
|
11 |
+
offset: number,
|
12 |
+
string: string
|
13 |
+
): void {
|
14 |
+
for (let i = 0; i < string.length; i++) {
|
15 |
+
view.setUint8(offset + i, string.charCodeAt(i));
|
16 |
+
}
|
17 |
+
};
|
18 |
+
|
19 |
+
writeString(view, offset, "RIFF");
|
20 |
+
offset += 4;
|
21 |
+
view.setUint32(offset, length - 8, true);
|
22 |
+
offset += 4;
|
23 |
+
writeString(view, offset, "WAVE");
|
24 |
+
offset += 4;
|
25 |
+
writeString(view, offset, "fmt ");
|
26 |
+
offset += 4;
|
27 |
+
view.setUint32(offset, 16, true);
|
28 |
+
offset += 4; // Sub-chunk size, 16 for PCM
|
29 |
+
view.setUint16(offset, 1, true);
|
30 |
+
offset += 2; // PCM format
|
31 |
+
view.setUint16(offset, numOfChan, true);
|
32 |
+
offset += 2;
|
33 |
+
view.setUint32(offset, audioBuffer.sampleRate, true);
|
34 |
+
offset += 4;
|
35 |
+
view.setUint32(offset, audioBuffer.sampleRate * 2 * numOfChan, true);
|
36 |
+
offset += 4;
|
37 |
+
view.setUint16(offset, numOfChan * 2, true);
|
38 |
+
offset += 2;
|
39 |
+
view.setUint16(offset, 16, true);
|
40 |
+
offset += 2;
|
41 |
+
writeString(view, offset, "data");
|
42 |
+
offset += 4;
|
43 |
+
view.setUint32(offset, audioBuffer.length * numOfChan * 2, true);
|
44 |
+
offset += 4;
|
45 |
+
|
46 |
+
// Write PCM audio data
|
47 |
+
for (let i = 0; i < audioBuffer.numberOfChannels; i++) {
|
48 |
+
const channel = audioBuffer.getChannelData(i);
|
49 |
+
for (let j = 0; j < channel.length; j++) {
|
50 |
+
view.setInt16(offset, channel[j] * 0xffff, true);
|
51 |
+
offset += 2;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
return new Uint8Array(buffer);
|
56 |
+
}
|
src/frontend/shared/types.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export type WaveformOptions = {
|
2 |
+
waveform_color?: string;
|
3 |
+
waveform_progress_color?: string;
|
4 |
+
show_controls?: boolean;
|
5 |
+
skip_length?: number;
|
6 |
+
};
|
src/frontend/shared/utils.ts
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type WaveSurfer from "wavesurfer.js";
|
2 |
+
import Regions from "wavesurfer.js/dist/plugins/regions.js";
|
3 |
+
import { audioBufferToWav } from "./audioBufferToWav";
|
4 |
+
|
5 |
+
export interface LoadedParams {
|
6 |
+
autoplay?: boolean;
|
7 |
+
}
|
8 |
+
|
9 |
+
export function blob_to_data_url(blob: Blob): Promise<string> {
|
10 |
+
return new Promise((fulfill, reject) => {
|
11 |
+
let reader = new FileReader();
|
12 |
+
reader.onerror = reject;
|
13 |
+
reader.onload = () => fulfill(reader.result as string);
|
14 |
+
reader.readAsDataURL(blob);
|
15 |
+
});
|
16 |
+
}
|
17 |
+
|
18 |
+
export const process_audio = async (
|
19 |
+
audioBuffer: AudioBuffer,
|
20 |
+
start?: number,
|
21 |
+
end?: number
|
22 |
+
): Promise<Uint8Array> => {
|
23 |
+
const audioContext = new AudioContext();
|
24 |
+
const numberOfChannels = audioBuffer.numberOfChannels;
|
25 |
+
const sampleRate = audioBuffer.sampleRate;
|
26 |
+
|
27 |
+
let trimmedLength = audioBuffer.length;
|
28 |
+
let startOffset = 0;
|
29 |
+
|
30 |
+
if (start && end) {
|
31 |
+
startOffset = Math.round(start * sampleRate);
|
32 |
+
const endOffset = Math.round(end * sampleRate);
|
33 |
+
trimmedLength = endOffset - startOffset;
|
34 |
+
}
|
35 |
+
|
36 |
+
const trimmedAudioBuffer = audioContext.createBuffer(
|
37 |
+
numberOfChannels,
|
38 |
+
trimmedLength,
|
39 |
+
sampleRate
|
40 |
+
);
|
41 |
+
|
42 |
+
for (let channel = 0; channel < numberOfChannels; channel++) {
|
43 |
+
const channelData = audioBuffer.getChannelData(channel);
|
44 |
+
const trimmedData = trimmedAudioBuffer.getChannelData(channel);
|
45 |
+
for (let i = 0; i < trimmedLength; i++) {
|
46 |
+
trimmedData[i] = channelData[startOffset + i];
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
return audioBufferToWav(trimmedAudioBuffer);
|
51 |
+
};
|
52 |
+
|
53 |
+
export function loaded(
|
54 |
+
node: HTMLAudioElement,
|
55 |
+
{ autoplay }: LoadedParams = {}
|
56 |
+
): void {
|
57 |
+
async function handle_playback(): Promise<void> {
|
58 |
+
if (!autoplay) return;
|
59 |
+
node.pause();
|
60 |
+
await node.play();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
export const skipAudio = (waveform: WaveSurfer, amount: number): void => {
|
65 |
+
if (!waveform) return;
|
66 |
+
waveform.skip(amount);
|
67 |
+
};
|
68 |
+
|
69 |
+
export const addRegion = (
|
70 |
+
waveform: WaveSurfer,
|
71 |
+
waveformRegions: Regions,
|
72 |
+
start: number,
|
73 |
+
end: number
|
74 |
+
): void => {
|
75 |
+
waveformRegions = waveform.registerPlugin(Regions.create());
|
76 |
+
|
77 |
+
waveformRegions.addRegion({
|
78 |
+
start: start,
|
79 |
+
end: end,
|
80 |
+
color: "rgba(255, 0, 0, 0.1)",
|
81 |
+
drag: true,
|
82 |
+
resize: true
|
83 |
+
});
|
84 |
+
};
|
85 |
+
|
86 |
+
export const getSkipRewindAmount = (
|
87 |
+
audioDuration: number,
|
88 |
+
skip_length?: number | null
|
89 |
+
): number => {
|
90 |
+
return (audioDuration / 100) * (skip_length || 5);
|
91 |
+
};
|
src/frontend/static/StaticAudio.svelte
ADDED
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { uploadToHuggingFace } from "@gradio/utils";
|
3 |
+
import { Empty } from "@gradio/atoms";
|
4 |
+
import { ShareButton, IconButton, BlockLabel } from "@gradio/atoms";
|
5 |
+
import { Download, Music } from "@gradio/icons";
|
6 |
+
import type { I18nFormatter } from "@gradio/utils";
|
7 |
+
import AudioPlayer from "../player/AudioPlayer.svelte";
|
8 |
+
import { get_fetchable_url_or_file } from "@gradio/client";
|
9 |
+
import { createEventDispatcher, onMount } from "svelte";
|
10 |
+
import { FileData } from "@gradio/client";
|
11 |
+
|
12 |
+
export let value: null | FileData = null;
|
13 |
+
export let image: null | string | FileData = null;
|
14 |
+
export let label: string;
|
15 |
+
export let show_label = true;
|
16 |
+
export let show_download_button = true;
|
17 |
+
export let show_share_button = false;
|
18 |
+
export let i18n: I18nFormatter;
|
19 |
+
export let waveform_settings = {};
|
20 |
+
export let root = "";
|
21 |
+
export let proxy_url: string | null = null;
|
22 |
+
let image_path: string;
|
23 |
+
$: {
|
24 |
+
if (image instanceof FileData) {
|
25 |
+
image_path = image.path;
|
26 |
+
} else {
|
27 |
+
image_path = get_fetchable_url_or_file(image, root, proxy_url);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
const dispatch = createEventDispatcher<{
|
32 |
+
change: FileData;
|
33 |
+
play: undefined;
|
34 |
+
pause: undefined;
|
35 |
+
end: undefined;
|
36 |
+
stop: undefined;
|
37 |
+
}>();
|
38 |
+
$: value && dispatch("change", value);
|
39 |
+
|
40 |
+
let audioElement;
|
41 |
+
let isPlaying = false;
|
42 |
+
|
43 |
+
function play_audio() {
|
44 |
+
if (isPlaying) {
|
45 |
+
audioElement.pause();
|
46 |
+
isPlaying = false;
|
47 |
+
return;
|
48 |
+
} else {
|
49 |
+
audioElement.play();
|
50 |
+
isPlaying = true;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
</script>
|
54 |
+
|
55 |
+
{#if value !== null}
|
56 |
+
<div class="icon-buttons">
|
57 |
+
{#if show_share_button}
|
58 |
+
<ShareButton
|
59 |
+
{i18n}
|
60 |
+
on:error
|
61 |
+
on:share
|
62 |
+
formatter={async (value) => {
|
63 |
+
if (!value) return "";
|
64 |
+
let url = await uploadToHuggingFace(value.url, "url");
|
65 |
+
return `<audio controls src="${url}"></audio>`;
|
66 |
+
}}
|
67 |
+
{value}
|
68 |
+
/>
|
69 |
+
{/if}
|
70 |
+
</div>
|
71 |
+
<audio src={value.url} controls bind:this={audioElement}/>
|
72 |
+
{#if image}
|
73 |
+
<div class="image-container" on:click={play_audio} role="button" tabindex="0" aria-hidden="true">
|
74 |
+
<img class="image-player" src={image_path} alt="test" />
|
75 |
+
{#if !isPlaying}
|
76 |
+
<!-- Play button -->
|
77 |
+
<svg class="play-icon" viewBox="0 0 24 24" style="pointer-events: none;">
|
78 |
+
<polygon points="5,3 19,12 5,21" fill="#fff" />
|
79 |
+
</svg>
|
80 |
+
{:else}
|
81 |
+
<!-- Pause button -->
|
82 |
+
<svg class="pause-icon" viewBox="0 0 24 24" style="pointer-events: none;">
|
83 |
+
<rect x="6" y="4" width="4" height="16" fill="#fff" />
|
84 |
+
<rect x="14" y="4" width="4" height="16" fill="#fff" />
|
85 |
+
</svg>
|
86 |
+
{/if}
|
87 |
+
</div>
|
88 |
+
{:else}
|
89 |
+
<div class="circle-container" on:click={play_audio} role="button" tabindex="0" aria-hidden="true">
|
90 |
+
{#each Array(15) as _, i (i)}
|
91 |
+
<div class={`waveform-bar ${isPlaying ? `waveform-animation-${i % 5}` : ''}`} style={`height: ${20 + (i % 5) * 10}%`}></div>
|
92 |
+
{/each}
|
93 |
+
{#if !isPlaying}
|
94 |
+
<!-- Play button -->
|
95 |
+
<svg class="play-icon" viewBox="0 0 24 24" style="pointer-events: none;">
|
96 |
+
<polygon points="5,3 19,12 5,21" fill="#fff" />
|
97 |
+
</svg>
|
98 |
+
{:else}
|
99 |
+
<!-- Pause button -->
|
100 |
+
<svg class="pause-icon" viewBox="0 0 24 24" style="pointer-events: none;">
|
101 |
+
<rect x="6" y="4" width="4" height="16" fill="#fff" />
|
102 |
+
<rect x="14" y="4" width="4" height="16" fill="#fff" />
|
103 |
+
</svg>
|
104 |
+
{/if}
|
105 |
+
</div>
|
106 |
+
{/if}
|
107 |
+
{:else}
|
108 |
+
<Empty size="small">
|
109 |
+
<Music />
|
110 |
+
</Empty>
|
111 |
+
{/if}
|
112 |
+
|
113 |
+
<style>
|
114 |
+
|
115 |
+
audio {
|
116 |
+
display: none;
|
117 |
+
}
|
118 |
+
|
119 |
+
.image-container {
|
120 |
+
position: relative;
|
121 |
+
width: 350px;
|
122 |
+
height: 350px;
|
123 |
+
margin: auto;
|
124 |
+
}
|
125 |
+
|
126 |
+
.image-player {
|
127 |
+
position: absolute;
|
128 |
+
top: 0;
|
129 |
+
left: 0;
|
130 |
+
width: 100%;
|
131 |
+
height: 100%;
|
132 |
+
border-radius: 50%;
|
133 |
+
object-fit: cover;
|
134 |
+
}
|
135 |
+
|
136 |
+
.play-icon, .pause-icon {
|
137 |
+
position: absolute;
|
138 |
+
top: 50%;
|
139 |
+
left: 50%;
|
140 |
+
width: 75px;
|
141 |
+
height: 75px;
|
142 |
+
transform: translate(-50%, -50%);
|
143 |
+
}
|
144 |
+
|
145 |
+
.pause-icon {
|
146 |
+
opacity: 0;
|
147 |
+
transition: opacity 0.3s;
|
148 |
+
}
|
149 |
+
|
150 |
+
.image-container:hover .pause-icon, .circle-container:hover .pause-icon {
|
151 |
+
opacity: 1;
|
152 |
+
}
|
153 |
+
|
154 |
+
.circle-container:hover .waveform-bar {
|
155 |
+
opacity: 0.5;
|
156 |
+
}
|
157 |
+
|
158 |
+
.circle-container {
|
159 |
+
position: relative;
|
160 |
+
width: 350px;
|
161 |
+
height: 350px;
|
162 |
+
margin: auto;
|
163 |
+
border-radius: 50%;
|
164 |
+
border: 3px solid white;
|
165 |
+
position: relative;
|
166 |
+
overflow: hidden;
|
167 |
+
display: flex;
|
168 |
+
align-items: center;
|
169 |
+
justify-content: center;
|
170 |
+
}
|
171 |
+
.waveform-bar {
|
172 |
+
background-color: white;
|
173 |
+
width: 2%;
|
174 |
+
height: 20%;
|
175 |
+
margin: 0 1%;
|
176 |
+
border-radius: 5px;
|
177 |
+
opacity: 0.5;
|
178 |
+
transform-origin: bottom;
|
179 |
+
}
|
180 |
+
|
181 |
+
.waveform-animation-0 {
|
182 |
+
animation: waveAnimation0 1s infinite ease-in-out;
|
183 |
+
opacity: 1;
|
184 |
+
}
|
185 |
+
|
186 |
+
.waveform-animation-1 {
|
187 |
+
animation: waveAnimation1 1.5s infinite ease-in-out;
|
188 |
+
opacity: 1;
|
189 |
+
}
|
190 |
+
|
191 |
+
.waveform-animation-2 {
|
192 |
+
animation: waveAnimation2 3s infinite ease-in-out;
|
193 |
+
opacity: 1;
|
194 |
+
}
|
195 |
+
|
196 |
+
|
197 |
+
.waveform-animation-3 {
|
198 |
+
animation: waveAnimation3 2s infinite ease-in-out;
|
199 |
+
opacity: 1;
|
200 |
+
}
|
201 |
+
|
202 |
+
.waveform-animation-4 {
|
203 |
+
animation: waveAnimation4 2.5s infinite ease-in-out;
|
204 |
+
opacity: 1;
|
205 |
+
}
|
206 |
+
|
207 |
+
.waveform-animation-5 {
|
208 |
+
animation: waveAnimation5 3.5s infinite ease-in-out;
|
209 |
+
opacity: 1;
|
210 |
+
}
|
211 |
+
|
212 |
+
|
213 |
+
@keyframes waveAnimation0 {
|
214 |
+
0%, 100% { height: 50%; }
|
215 |
+
50% { height: 15%; }
|
216 |
+
}
|
217 |
+
|
218 |
+
@keyframes waveAnimation1 {
|
219 |
+
0%, 100% { height: 45%; }
|
220 |
+
50% { height: 25%; }
|
221 |
+
}
|
222 |
+
|
223 |
+
@keyframes waveAnimation2 {
|
224 |
+
0%, 100% { height: 40%; }
|
225 |
+
50% { height: 60%; }
|
226 |
+
}
|
227 |
+
|
228 |
+
@keyframes waveAnimation3 {
|
229 |
+
0%, 100% { height: 70%; }
|
230 |
+
50% { height: 25%; }
|
231 |
+
}
|
232 |
+
|
233 |
+
@keyframes waveAnimation4 {
|
234 |
+
0%, 100% { height: 25%; }
|
235 |
+
50% { height: 70%; }
|
236 |
+
}
|
237 |
+
|
238 |
+
@keyframes waveAnimation5 {
|
239 |
+
0%, 100% { height: 60%; }
|
240 |
+
50% { height: 15%; }
|
241 |
+
}
|
242 |
+
</style>
|
src/frontend/streaming/StreamAudio.svelte
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { onMount } from "svelte";
|
3 |
+
import type { I18nFormatter } from "@gradio/utils";
|
4 |
+
import WaveSurfer from "wavesurfer.js";
|
5 |
+
import RecordPlugin from "wavesurfer.js/dist/plugins/record.js";
|
6 |
+
|
7 |
+
export let recording = false;
|
8 |
+
export let paused_recording = false;
|
9 |
+
export let stop: () => void;
|
10 |
+
export let record: () => void;
|
11 |
+
export let i18n: I18nFormatter;
|
12 |
+
export let waveform_settings = {};
|
13 |
+
|
14 |
+
let micWaveform: WaveSurfer;
|
15 |
+
let waveformRecord: RecordPlugin;
|
16 |
+
|
17 |
+
onMount(() => {
|
18 |
+
create_mic_waveform();
|
19 |
+
});
|
20 |
+
|
21 |
+
const create_mic_waveform = (): void => {
|
22 |
+
if (micWaveform !== undefined) micWaveform.destroy();
|
23 |
+
|
24 |
+
micWaveform = WaveSurfer.create({
|
25 |
+
...waveform_settings,
|
26 |
+
height: 100,
|
27 |
+
container: "#microphone"
|
28 |
+
});
|
29 |
+
|
30 |
+
waveformRecord = micWaveform.registerPlugin(RecordPlugin.create());
|
31 |
+
};
|
32 |
+
</script>
|
33 |
+
|
34 |
+
<div class="mic-wrap">
|
35 |
+
<div id="microphone" style:display={recording ? "block" : "none"} />
|
36 |
+
{#if recording}
|
37 |
+
<button
|
38 |
+
class={paused_recording ? "stop-button-paused" : "stop-button"}
|
39 |
+
on:click={() => {
|
40 |
+
waveformRecord.stopMic();
|
41 |
+
stop();
|
42 |
+
}}
|
43 |
+
>
|
44 |
+
<span class="record-icon">
|
45 |
+
<span class="pinger" />
|
46 |
+
<span class="dot" />
|
47 |
+
</span>
|
48 |
+
{paused_recording ? i18n("audio.pause") : i18n("audio.stop")}
|
49 |
+
</button>
|
50 |
+
{:else}
|
51 |
+
<button
|
52 |
+
class="record-button"
|
53 |
+
on:click={() => {
|
54 |
+
waveformRecord.startMic();
|
55 |
+
record();
|
56 |
+
}}
|
57 |
+
>
|
58 |
+
<span class="record-icon">
|
59 |
+
<span class="dot" />
|
60 |
+
</span>
|
61 |
+
{i18n("audio.record")}
|
62 |
+
</button>
|
63 |
+
{/if}
|
64 |
+
</div>
|
65 |
+
|
66 |
+
<style>
|
67 |
+
.mic-wrap {
|
68 |
+
display: block;
|
69 |
+
align-items: center;
|
70 |
+
margin: var(--spacing-xl);
|
71 |
+
}
|
72 |
+
|
73 |
+
.stop-button-paused {
|
74 |
+
display: none;
|
75 |
+
height: var(--size-8);
|
76 |
+
width: var(--size-20);
|
77 |
+
background-color: var(--block-background-fill);
|
78 |
+
border-radius: var(--radius-3xl);
|
79 |
+
align-items: center;
|
80 |
+
border: 1px solid var(--neutral-400);
|
81 |
+
margin-right: 5px;
|
82 |
+
}
|
83 |
+
|
84 |
+
.stop-button-paused::before {
|
85 |
+
content: "";
|
86 |
+
height: var(--size-4);
|
87 |
+
width: var(--size-4);
|
88 |
+
border-radius: var(--radius-full);
|
89 |
+
background: var(--primary-600);
|
90 |
+
margin: 0 var(--spacing-xl);
|
91 |
+
}
|
92 |
+
|
93 |
+
.stop-button::before {
|
94 |
+
content: "";
|
95 |
+
height: var(--size-4);
|
96 |
+
width: var(--size-4);
|
97 |
+
border-radius: var(--radius-full);
|
98 |
+
background: var(--primary-600);
|
99 |
+
margin: 0 var(--spacing-xl);
|
100 |
+
animation: scaling 1800ms infinite;
|
101 |
+
}
|
102 |
+
|
103 |
+
.stop-button {
|
104 |
+
height: var(--size-8);
|
105 |
+
width: var(--size-20);
|
106 |
+
background-color: var(--block-background-fill);
|
107 |
+
border-radius: var(--radius-3xl);
|
108 |
+
align-items: center;
|
109 |
+
border: 1px solid var(--primary-600);
|
110 |
+
margin-right: 5px;
|
111 |
+
display: flex;
|
112 |
+
}
|
113 |
+
|
114 |
+
.record-button::before {
|
115 |
+
content: "";
|
116 |
+
height: var(--size-4);
|
117 |
+
width: var(--size-4);
|
118 |
+
border-radius: var(--radius-full);
|
119 |
+
background: var(--primary-600);
|
120 |
+
margin: 0 var(--spacing-xl);
|
121 |
+
}
|
122 |
+
|
123 |
+
.record-button {
|
124 |
+
height: var(--size-8);
|
125 |
+
width: var(--size-24);
|
126 |
+
background-color: var(--block-background-fill);
|
127 |
+
border-radius: var(--radius-3xl);
|
128 |
+
display: flex;
|
129 |
+
align-items: center;
|
130 |
+
border: 1px solid var(--neutral-400);
|
131 |
+
}
|
132 |
+
</style>
|
src/pyproject.toml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[build-system]
|
2 |
+
requires = [
|
3 |
+
"hatchling",
|
4 |
+
"hatch-requirements-txt",
|
5 |
+
"hatch-fancy-pypi-readme>=22.5.0",
|
6 |
+
]
|
7 |
+
build-backend = "hatchling.build"
|
8 |
+
|
9 |
+
[project]
|
10 |
+
name = "gradio_unifiedaudio"
|
11 |
+
version = "0.0.2"
|
12 |
+
description = "Python library for easily interacting with trained machine learning models"
|
13 |
+
readme = "README.md"
|
14 |
+
license = "Apache-2.0"
|
15 |
+
requires-python = ">=3.8"
|
16 |
+
authors = [{ name = "YOUR NAME", email = "YOUREMAIL@domain.com" }]
|
17 |
+
keywords = [
|
18 |
+
"machine learning",
|
19 |
+
"reproducibility",
|
20 |
+
"visualization",
|
21 |
+
"gradio",
|
22 |
+
"gradio custom component",
|
23 |
+
"gradio-template-Audio"
|
24 |
+
]
|
25 |
+
# Add dependencies here
|
26 |
+
dependencies = ["gradio>=4.0,<5.0"]
|
27 |
+
classifiers = [
|
28 |
+
'Development Status :: 3 - Alpha',
|
29 |
+
'License :: OSI Approved :: Apache Software License',
|
30 |
+
'Operating System :: OS Independent',
|
31 |
+
'Programming Language :: Python :: 3',
|
32 |
+
'Programming Language :: Python :: 3 :: Only',
|
33 |
+
'Programming Language :: Python :: 3.8',
|
34 |
+
'Programming Language :: Python :: 3.9',
|
35 |
+
'Programming Language :: Python :: 3.10',
|
36 |
+
'Programming Language :: Python :: 3.11',
|
37 |
+
'Topic :: Scientific/Engineering',
|
38 |
+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
39 |
+
'Topic :: Scientific/Engineering :: Visualization',
|
40 |
+
]
|
41 |
+
|
42 |
+
[project.optional-dependencies]
|
43 |
+
dev = ["build", "twine"]
|
44 |
+
|
45 |
+
[tool.hatch.build]
|
46 |
+
artifacts = ["/backend/gradio_unifiedaudio/templates", "*.pyi", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates", "backend/gradio_unifiedaudio/templates"]
|
47 |
+
|
48 |
+
[tool.hatch.build.targets.wheel]
|
49 |
+
packages = ["/backend/gradio_unifiedaudio"]
|