flet-audio-recorder 0.2.0.dev17__tar.gz → 0.2.0.dev18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flet_audio_recorder-0.2.0.dev18/PKG-INFO +37 -0
- flet_audio_recorder-0.2.0.dev18/README.md +23 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/pyproject.toml +10 -1
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flet_audio_recorder/audio_recorder.py +211 -3
- flet_audio_recorder-0.2.0.dev18/src/flet_audio_recorder.egg-info/PKG-INFO +37 -0
- flet_audio_recorder-0.2.0.dev17/PKG-INFO +0 -93
- flet_audio_recorder-0.2.0.dev17/README.md +0 -79
- flet_audio_recorder-0.2.0.dev17/src/flet_audio_recorder.egg-info/PKG-INFO +0 -93
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/setup.cfg +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flet_audio_recorder/__init__.py +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flet_audio_recorder.egg-info/SOURCES.txt +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flet_audio_recorder.egg-info/dependency_links.txt +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flet_audio_recorder.egg-info/requires.txt +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flet_audio_recorder.egg-info/top_level.txt +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/CHANGELOG.md +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/LICENSE +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/README.md +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/analysis_options.yaml +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/lib/flet_audio_recorder.dart +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/lib/src/audio_recorder.dart +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/lib/src/create_control.dart +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/lib/src/utils/audio_recorder.dart +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/pubspec.lock +0 -0
- {flet_audio_recorder-0.2.0.dev17 → flet_audio_recorder-0.2.0.dev18}/src/flutter/flet_audio_recorder/pubspec.yaml +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: flet-audio-recorder
|
|
3
|
+
Version: 0.2.0.dev18
|
|
4
|
+
Summary: AudioRecorder control for Flet
|
|
5
|
+
Author-email: Flet contributors <hello@flet.dev>
|
|
6
|
+
Project-URL: Homepage, https://flet.dev
|
|
7
|
+
Project-URL: Documentation, https://flet.dev/docs/controls/audiorecorder
|
|
8
|
+
Project-URL: Repository, https://github.com/flet-dev/flet-audio-recorder
|
|
9
|
+
Project-URL: Issues, https://github.com/flet-dev/flet-audio-recorder/issues
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: flet>=0.25.2
|
|
14
|
+
|
|
15
|
+
# AudioRecorder
|
|
16
|
+
|
|
17
|
+
Audio recorder from microphone to a given file path. Works on macOS, Linux, Windows, iOS, Android and web.
|
|
18
|
+
Based on the [record](https://pub.dev/packages/record) Dart/Flutter package.
|
|
19
|
+
|
|
20
|
+
**NOTE:** On Linux, encoding is provided by [fmedia](https://stsaz.github.io/fmedia/) which must be installed separately.
|
|
21
|
+
|
|
22
|
+
AudioRecorder control is non-visual and should be added to `page.overlay` list.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Add `flet-audio-recorder` as dependency to `pyproject.toml` of your Flet app:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
dependencies = [
|
|
30
|
+
"flet-audio-recorder",
|
|
31
|
+
"flet>=0.27.4",
|
|
32
|
+
]
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Documentation
|
|
36
|
+
|
|
37
|
+
https://flet-dev.github.io/flet-audio-recorder/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# AudioRecorder
|
|
2
|
+
|
|
3
|
+
Audio recorder from microphone to a given file path. Works on macOS, Linux, Windows, iOS, Android and web.
|
|
4
|
+
Based on the [record](https://pub.dev/packages/record) Dart/Flutter package.
|
|
5
|
+
|
|
6
|
+
**NOTE:** On Linux, encoding is provided by [fmedia](https://stsaz.github.io/fmedia/) which must be installed separately.
|
|
7
|
+
|
|
8
|
+
AudioRecorder control is non-visual and should be added to `page.overlay` list.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Add `flet-audio-recorder` as dependency to `pyproject.toml` of your Flet app:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
dependencies = [
|
|
16
|
+
"flet-audio-recorder",
|
|
17
|
+
"flet>=0.27.4",
|
|
18
|
+
]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Documentation
|
|
22
|
+
|
|
23
|
+
https://flet-dev.github.io/flet-audio-recorder/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "flet-audio-recorder"
|
|
3
|
-
version = "0.2.0.
|
|
3
|
+
version = "0.2.0.dev18"
|
|
4
4
|
description = "AudioRecorder control for Flet"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -26,8 +26,17 @@ Issues = "https://github.com/flet-dev/flet-audio-recorder/issues"
|
|
|
26
26
|
[tool.uv]
|
|
27
27
|
dev-dependencies = [
|
|
28
28
|
"flet[all]>=0.25.2",
|
|
29
|
+
"mkdocs",
|
|
30
|
+
"mkdocs-material",
|
|
31
|
+
"mkdocstrings[python]"
|
|
29
32
|
]
|
|
30
33
|
|
|
34
|
+
[tool.poetry.group.dev.dependencies]
|
|
35
|
+
flet = {extras = ["all"], version = "0.27.4"}
|
|
36
|
+
mkdocs = "^1.0"
|
|
37
|
+
mkdocstrings = { extras = ["python"], version = "^0.10" }
|
|
38
|
+
mkdocs-material = "^8.0"
|
|
39
|
+
|
|
31
40
|
[tool.setuptools]
|
|
32
41
|
license-files = []
|
|
33
42
|
|
|
@@ -11,6 +11,13 @@ from flet.utils import deprecated
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class AudioRecorderState(Enum):
|
|
14
|
+
"""
|
|
15
|
+
The available AudioRecorder states are:
|
|
16
|
+
|
|
17
|
+
- `STOPPED`
|
|
18
|
+
- `RECORDING`
|
|
19
|
+
- `PAUSED`
|
|
20
|
+
"""
|
|
14
21
|
STOPPED = "stopped"
|
|
15
22
|
RECORDING = "recording"
|
|
16
23
|
PAUSED = "paused"
|
|
@@ -18,11 +25,29 @@ class AudioRecorderState(Enum):
|
|
|
18
25
|
|
|
19
26
|
class AudioRecorderStateChangeEvent(ControlEvent):
|
|
20
27
|
def __init__(self, e: ControlEvent):
|
|
28
|
+
"""The current state of the audio recorder.
|
|
29
|
+
|
|
30
|
+
Value is of type [AudioRecorderState](audiorecorderstate.md)."""
|
|
21
31
|
super().__init__(e.target, e.name, e.data, e.control, e.page)
|
|
22
32
|
self.state: AudioRecorderState = AudioRecorderState(e.data)
|
|
23
33
|
|
|
24
34
|
|
|
25
35
|
class AudioEncoder(Enum):
|
|
36
|
+
"""
|
|
37
|
+
The `AudioEncoder` enum represents the different audio encoders supported by the audio recorder.
|
|
38
|
+
|
|
39
|
+
The available encoders are:
|
|
40
|
+
|
|
41
|
+
- `AACLC`: Advanced Audio Codec Low Complexity. A commonly used encoder for streaming and general audio recording.
|
|
42
|
+
- `AACELD`: Advanced Audio Codec Enhanced Low Delay. Suitable for low-latency applications like VoIP.
|
|
43
|
+
- `AACHE`: Advanced Audio Codec High Efficiency. Optimized for high-quality audio at lower bit rates.
|
|
44
|
+
- `AMRNB`: Adaptive Multi-Rate Narrow Band. Used for speech audio in mobile communication.
|
|
45
|
+
- `AMRWB`: Adaptive Multi-Rate Wide Band. Used for higher-quality speech audio.
|
|
46
|
+
- `OPUS`: A codec designed for both speech and audio applications, known for its versatility.
|
|
47
|
+
- `FLAC`: Free Lossless Audio Codec. Provides high-quality lossless audio compression.
|
|
48
|
+
- `WAV`: Standard audio format used for raw, uncompressed audio data.
|
|
49
|
+
- `PCM16BITS`: Pulse Code Modulation with 16-bit depth, used for high-fidelity audio.
|
|
50
|
+
"""
|
|
26
51
|
AACLC = "aacLc"
|
|
27
52
|
AACELD = "aacEld"
|
|
28
53
|
AACHE = "aacHe"
|
|
@@ -34,13 +59,13 @@ class AudioEncoder(Enum):
|
|
|
34
59
|
PCM16BITS = "pcm16bits"
|
|
35
60
|
|
|
36
61
|
|
|
62
|
+
|
|
37
63
|
class AudioRecorder(Control):
|
|
38
64
|
"""
|
|
39
65
|
A control that allows you to record audio from your device.
|
|
40
66
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Online docs: https://flet.dev/docs/controls/audiorecorder
|
|
67
|
+
This control can record audio using different audio encoders and also allows configuration
|
|
68
|
+
of various audio recording parameters such as noise suppression, echo cancellation, and more.
|
|
44
69
|
"""
|
|
45
70
|
|
|
46
71
|
def __init__(
|
|
@@ -84,6 +109,18 @@ class AudioRecorder(Control):
|
|
|
84
109
|
def start_recording(
|
|
85
110
|
self, output_path: str = None, wait_timeout: Optional[float] = 10
|
|
86
111
|
) -> bool:
|
|
112
|
+
"""
|
|
113
|
+
Starts recording audio and saves it to the specified output path.
|
|
114
|
+
|
|
115
|
+
If not on the web, the `output_path` parameter must be provided.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
output_path: The file path where the audio will be saved. It must be specified if not on web.
|
|
119
|
+
wait_timeout: The time in seconds to wait for the recording to start. Default is 10.
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
bool: `True` if recording was successfully started, `False` otherwise.
|
|
123
|
+
"""
|
|
87
124
|
assert (
|
|
88
125
|
self.page.web or output_path
|
|
89
126
|
), "output_path must be provided when not on web"
|
|
@@ -96,6 +133,15 @@ class AudioRecorder(Control):
|
|
|
96
133
|
return started == "true"
|
|
97
134
|
|
|
98
135
|
def is_recording(self, wait_timeout: Optional[float] = 5) -> bool:
|
|
136
|
+
"""
|
|
137
|
+
Checks whether the audio recorder is currently recording.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
bool: `True` if the recorder is currently recording, `False` otherwise.
|
|
144
|
+
"""
|
|
99
145
|
recording = self.invoke_method(
|
|
100
146
|
"is_recording",
|
|
101
147
|
wait_for_result=True,
|
|
@@ -104,6 +150,15 @@ class AudioRecorder(Control):
|
|
|
104
150
|
return recording == "true"
|
|
105
151
|
|
|
106
152
|
async def is_recording_async(self, wait_timeout: Optional[float] = 5) -> bool:
|
|
153
|
+
"""
|
|
154
|
+
Asynchronously checks whether the audio recorder is currently recording.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
bool: `True` if the recorder is currently recording, `False` otherwise.
|
|
161
|
+
"""
|
|
107
162
|
recording = await self.invoke_method_async(
|
|
108
163
|
"is_recording",
|
|
109
164
|
wait_for_result=True,
|
|
@@ -112,6 +167,15 @@ class AudioRecorder(Control):
|
|
|
112
167
|
return recording == "true"
|
|
113
168
|
|
|
114
169
|
def stop_recording(self, wait_timeout: Optional[float] = 5) -> Optional[str]:
|
|
170
|
+
"""
|
|
171
|
+
Stops the audio recording and optionally returns the path to the saved file.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
Optional[str]: The file path where the audio was saved or `None` if not applicable.
|
|
178
|
+
"""
|
|
115
179
|
return self.invoke_method(
|
|
116
180
|
"stop_recording",
|
|
117
181
|
wait_for_result=True,
|
|
@@ -121,6 +185,15 @@ class AudioRecorder(Control):
|
|
|
121
185
|
async def stop_recording_async(
|
|
122
186
|
self, wait_timeout: Optional[float] = 10
|
|
123
187
|
) -> Optional[str]:
|
|
188
|
+
"""
|
|
189
|
+
Asynchronously stops the audio recording and optionally returns the path to the saved file.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
wait_timeout: The time in seconds to wait for the result. Default is 10.
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
Optional[str]: The file path where the audio was saved or `None` if not applicable.
|
|
196
|
+
"""
|
|
124
197
|
return await self.invoke_method_async(
|
|
125
198
|
"stop_recording",
|
|
126
199
|
wait_for_result=True,
|
|
@@ -128,6 +201,12 @@ class AudioRecorder(Control):
|
|
|
128
201
|
)
|
|
129
202
|
|
|
130
203
|
def cancel_recording(self, wait_timeout: Optional[float] = 5) -> None:
|
|
204
|
+
"""
|
|
205
|
+
Cancels the current audio recording.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
209
|
+
"""
|
|
131
210
|
self.invoke_method(
|
|
132
211
|
"cancel_recording",
|
|
133
212
|
wait_for_result=True,
|
|
@@ -135,12 +214,27 @@ class AudioRecorder(Control):
|
|
|
135
214
|
)
|
|
136
215
|
|
|
137
216
|
def resume_recording(self):
|
|
217
|
+
"""
|
|
218
|
+
Resumes a paused audio recording.
|
|
219
|
+
"""
|
|
138
220
|
self.invoke_method("resume_recording")
|
|
139
221
|
|
|
140
222
|
def pause_recording(self):
|
|
223
|
+
"""
|
|
224
|
+
Pauses the ongoing audio recording.
|
|
225
|
+
"""
|
|
141
226
|
self.invoke_method("pause_recording")
|
|
142
227
|
|
|
143
228
|
def is_paused(self, wait_timeout: Optional[float] = 5) -> bool:
|
|
229
|
+
"""
|
|
230
|
+
Checks whether the audio recorder is currently paused.
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
234
|
+
|
|
235
|
+
Returns:
|
|
236
|
+
bool: `True` if the recorder is paused, `False` otherwise.
|
|
237
|
+
"""
|
|
144
238
|
paused = self.invoke_method(
|
|
145
239
|
"is_paused",
|
|
146
240
|
wait_for_result=True,
|
|
@@ -149,6 +243,15 @@ class AudioRecorder(Control):
|
|
|
149
243
|
return paused == "true"
|
|
150
244
|
|
|
151
245
|
async def is_paused_async(self, wait_timeout: Optional[float] = 5) -> bool:
|
|
246
|
+
"""
|
|
247
|
+
Asynchronously checks whether the audio recorder is currently paused.
|
|
248
|
+
|
|
249
|
+
Args:
|
|
250
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
251
|
+
|
|
252
|
+
Returns:
|
|
253
|
+
bool: `True` if the recorder is paused, `False` otherwise.
|
|
254
|
+
"""
|
|
152
255
|
supported = await self.invoke_method_async(
|
|
153
256
|
"is_paused",
|
|
154
257
|
wait_for_result=True,
|
|
@@ -159,6 +262,16 @@ class AudioRecorder(Control):
|
|
|
159
262
|
def is_supported_encoder(
|
|
160
263
|
self, encoder: AudioEncoder, wait_timeout: Optional[float] = 5
|
|
161
264
|
) -> bool:
|
|
265
|
+
"""
|
|
266
|
+
Checks if the given audio encoder is supported by the recorder.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
encoder: The audio encoder to check.
|
|
270
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
bool: `True` if the encoder is supported, `False` otherwise.
|
|
274
|
+
"""
|
|
162
275
|
supported = self.invoke_method(
|
|
163
276
|
"is_supported_encoder",
|
|
164
277
|
{
|
|
@@ -174,6 +287,16 @@ class AudioRecorder(Control):
|
|
|
174
287
|
async def is_supported_encoder_async(
|
|
175
288
|
self, encoder: AudioEncoder, wait_timeout: Optional[float] = 5
|
|
176
289
|
) -> bool:
|
|
290
|
+
"""
|
|
291
|
+
Asynchronously checks if the given audio encoder is supported by the recorder.
|
|
292
|
+
|
|
293
|
+
Args:
|
|
294
|
+
encoder: The audio encoder to check.
|
|
295
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
296
|
+
|
|
297
|
+
Returns:
|
|
298
|
+
bool: `True` if the encoder is supported, `False` otherwise.
|
|
299
|
+
"""
|
|
177
300
|
supported = await self.invoke_method_async(
|
|
178
301
|
"is_supported_encoder",
|
|
179
302
|
{
|
|
@@ -187,6 +310,15 @@ class AudioRecorder(Control):
|
|
|
187
310
|
return supported == "true"
|
|
188
311
|
|
|
189
312
|
def get_input_devices(self, wait_timeout: Optional[float] = 5) -> dict:
|
|
313
|
+
"""
|
|
314
|
+
Retrieves the available input devices for recording.
|
|
315
|
+
|
|
316
|
+
Args:
|
|
317
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
318
|
+
|
|
319
|
+
Returns:
|
|
320
|
+
dict: A dictionary of available input devices.
|
|
321
|
+
"""
|
|
190
322
|
devices = self.invoke_method(
|
|
191
323
|
"get_input_devices",
|
|
192
324
|
wait_for_result=True,
|
|
@@ -195,6 +327,15 @@ class AudioRecorder(Control):
|
|
|
195
327
|
return json.loads(devices)
|
|
196
328
|
|
|
197
329
|
async def get_input_devices_async(self, wait_timeout: Optional[float] = 5) -> dict:
|
|
330
|
+
"""
|
|
331
|
+
Asynchronously retrieves the available input devices for recording.
|
|
332
|
+
|
|
333
|
+
Args:
|
|
334
|
+
wait_timeout: The time in seconds to wait for the result. Default is 5.
|
|
335
|
+
|
|
336
|
+
Returns:
|
|
337
|
+
dict: A dictionary of available input devices.
|
|
338
|
+
"""
|
|
198
339
|
devices = await self.invoke_method_async(
|
|
199
340
|
"get_input_devices",
|
|
200
341
|
wait_for_result=True,
|
|
@@ -203,6 +344,15 @@ class AudioRecorder(Control):
|
|
|
203
344
|
return json.loads(devices)
|
|
204
345
|
|
|
205
346
|
def has_permission(self, wait_timeout: Optional[float] = 10) -> bool:
|
|
347
|
+
"""
|
|
348
|
+
Checks if the app has permission to record audio.
|
|
349
|
+
|
|
350
|
+
Args:
|
|
351
|
+
wait_timeout: The time in seconds to wait for the result. Default is 10.
|
|
352
|
+
|
|
353
|
+
Returns:
|
|
354
|
+
bool: `True` if the app has permission, `False` otherwise.
|
|
355
|
+
"""
|
|
206
356
|
p = self.invoke_method(
|
|
207
357
|
"has_permission",
|
|
208
358
|
wait_for_result=True,
|
|
@@ -211,6 +361,15 @@ class AudioRecorder(Control):
|
|
|
211
361
|
return p == "true"
|
|
212
362
|
|
|
213
363
|
async def has_permission_async(self, wait_timeout: Optional[float] = 10) -> bool:
|
|
364
|
+
"""
|
|
365
|
+
Asynchronously checks if the app has permission to record audio.
|
|
366
|
+
|
|
367
|
+
Args:
|
|
368
|
+
wait_timeout: The time in seconds to wait for the result. Default is 10.
|
|
369
|
+
|
|
370
|
+
Returns:
|
|
371
|
+
bool: `True` if the app has permission, `False` otherwise.
|
|
372
|
+
"""
|
|
214
373
|
p = await self.invoke_method_async(
|
|
215
374
|
"has_permission",
|
|
216
375
|
wait_for_result=True,
|
|
@@ -221,6 +380,12 @@ class AudioRecorder(Control):
|
|
|
221
380
|
# audio_encoder
|
|
222
381
|
@property
|
|
223
382
|
def audio_encoder(self):
|
|
383
|
+
"""
|
|
384
|
+
The audio encoder to be used for recording.
|
|
385
|
+
|
|
386
|
+
Value is of type [`AudioEncoder`](audioencoder.md)
|
|
387
|
+
and defaults to `AudioEncoder.WAV`.
|
|
388
|
+
"""
|
|
224
389
|
return self._get_attr("audioEncoder")
|
|
225
390
|
|
|
226
391
|
@audio_encoder.setter
|
|
@@ -230,6 +395,13 @@ class AudioRecorder(Control):
|
|
|
230
395
|
# suppress_noise
|
|
231
396
|
@property
|
|
232
397
|
def suppress_noise(self) -> bool:
|
|
398
|
+
"""
|
|
399
|
+
Whether to suppress noise during recording.
|
|
400
|
+
|
|
401
|
+
Defaults to `False`.
|
|
402
|
+
|
|
403
|
+
If `True`, it reduces the background noise while recording.
|
|
404
|
+
"""
|
|
233
405
|
return self._get_attr("suppressNoise", data_type="bool", def_value=False)
|
|
234
406
|
|
|
235
407
|
@suppress_noise.setter
|
|
@@ -239,6 +411,13 @@ class AudioRecorder(Control):
|
|
|
239
411
|
# cancel_echo
|
|
240
412
|
@property
|
|
241
413
|
def cancel_echo(self) -> bool:
|
|
414
|
+
"""
|
|
415
|
+
Whether to cancel echo during recording.
|
|
416
|
+
|
|
417
|
+
Defaults to `False`.
|
|
418
|
+
|
|
419
|
+
If `True`, it reduces or cancels echo during recording.
|
|
420
|
+
"""
|
|
242
421
|
return self._get_attr("cancelEcho", data_type="bool", def_value=False)
|
|
243
422
|
|
|
244
423
|
@cancel_echo.setter
|
|
@@ -248,6 +427,13 @@ class AudioRecorder(Control):
|
|
|
248
427
|
# auto_gain
|
|
249
428
|
@property
|
|
250
429
|
def auto_gain(self) -> bool:
|
|
430
|
+
"""
|
|
431
|
+
Whether to automatically adjust the audio gain during recording.
|
|
432
|
+
|
|
433
|
+
Defaults to `False`.
|
|
434
|
+
|
|
435
|
+
If `True`, the audio gain is automatically adjusted to avoid distortion or clipping.
|
|
436
|
+
"""
|
|
251
437
|
return self._get_attr("autoGain", data_type="bool", def_value=False)
|
|
252
438
|
|
|
253
439
|
@auto_gain.setter
|
|
@@ -257,6 +443,11 @@ class AudioRecorder(Control):
|
|
|
257
443
|
# bit_rate
|
|
258
444
|
@property
|
|
259
445
|
def bit_rate(self) -> OptionalNumber:
|
|
446
|
+
"""
|
|
447
|
+
The bit rate of the audio recording.
|
|
448
|
+
|
|
449
|
+
This value is specified in kilobits per second (kbps). Defaults to `None`.
|
|
450
|
+
"""
|
|
260
451
|
return self._get_attr("bitRate")
|
|
261
452
|
|
|
262
453
|
@bit_rate.setter
|
|
@@ -266,6 +457,11 @@ class AudioRecorder(Control):
|
|
|
266
457
|
# sample_rate
|
|
267
458
|
@property
|
|
268
459
|
def sample_rate(self) -> OptionalNumber:
|
|
460
|
+
"""
|
|
461
|
+
The sample rate for the audio recording.
|
|
462
|
+
|
|
463
|
+
This value is specified in Hertz (Hz). Defaults to `None`.
|
|
464
|
+
"""
|
|
269
465
|
return self._get_attr("sampleRate")
|
|
270
466
|
|
|
271
467
|
@sample_rate.setter
|
|
@@ -275,6 +471,11 @@ class AudioRecorder(Control):
|
|
|
275
471
|
# channels_num
|
|
276
472
|
@property
|
|
277
473
|
def channels_num(self) -> OptionalNumber:
|
|
474
|
+
"""
|
|
475
|
+
The number of audio channels for the recording.
|
|
476
|
+
|
|
477
|
+
Can be `1` (mono) or `2` (stereo). Defaults to `None`.
|
|
478
|
+
"""
|
|
278
479
|
return self._get_attr("channels")
|
|
279
480
|
|
|
280
481
|
@channels_num.setter
|
|
@@ -285,6 +486,11 @@ class AudioRecorder(Control):
|
|
|
285
486
|
# on_state_changed
|
|
286
487
|
@property
|
|
287
488
|
def on_state_changed(self):
|
|
489
|
+
"""
|
|
490
|
+
Event handler that is triggered when the recording state changes.
|
|
491
|
+
|
|
492
|
+
This handler should accept an instance of [`AudioRecorderStateChangeEvent`](audiorecorderstatechangeevent.md).
|
|
493
|
+
"""
|
|
288
494
|
return self.__on_state_changed.handler
|
|
289
495
|
|
|
290
496
|
@on_state_changed.setter
|
|
@@ -292,3 +498,5 @@ class AudioRecorder(Control):
|
|
|
292
498
|
self, handler: OptionalEventCallable[AudioRecorderStateChangeEvent]
|
|
293
499
|
):
|
|
294
500
|
self.__on_state_changed.handler = handler
|
|
501
|
+
|
|
502
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: flet-audio-recorder
|
|
3
|
+
Version: 0.2.0.dev18
|
|
4
|
+
Summary: AudioRecorder control for Flet
|
|
5
|
+
Author-email: Flet contributors <hello@flet.dev>
|
|
6
|
+
Project-URL: Homepage, https://flet.dev
|
|
7
|
+
Project-URL: Documentation, https://flet.dev/docs/controls/audiorecorder
|
|
8
|
+
Project-URL: Repository, https://github.com/flet-dev/flet-audio-recorder
|
|
9
|
+
Project-URL: Issues, https://github.com/flet-dev/flet-audio-recorder/issues
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: flet>=0.25.2
|
|
14
|
+
|
|
15
|
+
# AudioRecorder
|
|
16
|
+
|
|
17
|
+
Audio recorder from microphone to a given file path. Works on macOS, Linux, Windows, iOS, Android and web.
|
|
18
|
+
Based on the [record](https://pub.dev/packages/record) Dart/Flutter package.
|
|
19
|
+
|
|
20
|
+
**NOTE:** On Linux, encoding is provided by [fmedia](https://stsaz.github.io/fmedia/) which must be installed separately.
|
|
21
|
+
|
|
22
|
+
AudioRecorder control is non-visual and should be added to `page.overlay` list.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Add `flet-audio-recorder` as dependency to `pyproject.toml` of your Flet app:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
dependencies = [
|
|
30
|
+
"flet-audio-recorder",
|
|
31
|
+
"flet>=0.27.4",
|
|
32
|
+
]
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Documentation
|
|
36
|
+
|
|
37
|
+
https://flet-dev.github.io/flet-audio-recorder/
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: flet-audio-recorder
|
|
3
|
-
Version: 0.2.0.dev17
|
|
4
|
-
Summary: AudioRecorder control for Flet
|
|
5
|
-
Author-email: Flet contributors <hello@flet.dev>
|
|
6
|
-
Project-URL: Homepage, https://flet.dev
|
|
7
|
-
Project-URL: Documentation, https://flet.dev/docs/controls/audiorecorder
|
|
8
|
-
Project-URL: Repository, https://github.com/flet-dev/flet-audio-recorder
|
|
9
|
-
Project-URL: Issues, https://github.com/flet-dev/flet-audio-recorder/issues
|
|
10
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
-
Requires-Python: >=3.8
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
Requires-Dist: flet>=0.25.2
|
|
14
|
-
|
|
15
|
-
# AudioRecorder control for Flet
|
|
16
|
-
|
|
17
|
-
`AudioRecorder` control for Flet.
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
Add `flet-audio-recorder` as dependency (`pyproject.toml` or `requirements.txt`) to your Flet project.
|
|
22
|
-
|
|
23
|
-
## Example
|
|
24
|
-
|
|
25
|
-
```py
|
|
26
|
-
|
|
27
|
-
import flet as ft
|
|
28
|
-
|
|
29
|
-
import flet_audio_recorder as far
|
|
30
|
-
|
|
31
|
-
async def main(page: ft.Page):
|
|
32
|
-
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
|
|
33
|
-
page.appbar = ft.AppBar(title=ft.Text("Audio Recorder"), center_title=True)
|
|
34
|
-
|
|
35
|
-
path = "test-audio-file.wav"
|
|
36
|
-
|
|
37
|
-
async def handle_start_recording(e):
|
|
38
|
-
print(f"StartRecording: {path}")
|
|
39
|
-
await audio_rec.start_recording_async(path)
|
|
40
|
-
|
|
41
|
-
async def handle_stop_recording(e):
|
|
42
|
-
output_path = await audio_rec.stop_recording_async()
|
|
43
|
-
print(f"StopRecording: {output_path}")
|
|
44
|
-
if page.web and output_path is not None:
|
|
45
|
-
await page.launch_url_async(output_path)
|
|
46
|
-
|
|
47
|
-
async def handle_list_devices(e):
|
|
48
|
-
devices = await audio_rec.get_input_devices_async()
|
|
49
|
-
print(devices)
|
|
50
|
-
|
|
51
|
-
async def handle_has_permission(e):
|
|
52
|
-
try:
|
|
53
|
-
print(f"HasPermission: {await audio_rec.has_permission_async()}")
|
|
54
|
-
except Exception as e:
|
|
55
|
-
print(e)
|
|
56
|
-
|
|
57
|
-
async def handle_pause(e):
|
|
58
|
-
print(f"isRecording: {await audio_rec.is_recording_async()}")
|
|
59
|
-
if await audio_rec.is_recording_async():
|
|
60
|
-
await audio_rec.pause_recording_async()
|
|
61
|
-
|
|
62
|
-
async def handle_resume(e):
|
|
63
|
-
print(f"isPaused: {await audio_rec.is_paused_async()}")
|
|
64
|
-
if await audio_rec.is_paused_async():
|
|
65
|
-
await audio_rec.resume_recording_async()
|
|
66
|
-
|
|
67
|
-
async def handle_audio_encoding_test(e):
|
|
68
|
-
for i in list(far.AudioEncoder):
|
|
69
|
-
print(f"{i}: {await audio_rec.is_supported_encoder_async(i)}")
|
|
70
|
-
|
|
71
|
-
async def handle_state_change(e):
|
|
72
|
-
print(f"State Changed: {e.data}")
|
|
73
|
-
|
|
74
|
-
audio_rec = far.AudioRecorder(
|
|
75
|
-
audio_encoder=far.AudioEncoder.WAV,
|
|
76
|
-
on_state_changed=handle_state_change,
|
|
77
|
-
)
|
|
78
|
-
page.overlay.append(audio_rec)
|
|
79
|
-
await page.update_async()
|
|
80
|
-
|
|
81
|
-
await page.add_async(
|
|
82
|
-
ft.ElevatedButton("Start Audio Recorder", on_click=handle_start_recording),
|
|
83
|
-
ft.ElevatedButton("Stop Audio Recorder", on_click=handle_stop_recording),
|
|
84
|
-
ft.ElevatedButton("List Devices", on_click=handle_list_devices),
|
|
85
|
-
ft.ElevatedButton("Pause Recording", on_click=handle_pause),
|
|
86
|
-
ft.ElevatedButton("Resume Recording", on_click=handle_resume),
|
|
87
|
-
ft.ElevatedButton("Test AudioEncodings", on_click=handle_audio_encoding_test),
|
|
88
|
-
ft.ElevatedButton("Has Permission", on_click=handle_has_permission),
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
ft.app(main)
|
|
93
|
-
```
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# AudioRecorder control for Flet
|
|
2
|
-
|
|
3
|
-
`AudioRecorder` control for Flet.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
Add `flet-audio-recorder` as dependency (`pyproject.toml` or `requirements.txt`) to your Flet project.
|
|
8
|
-
|
|
9
|
-
## Example
|
|
10
|
-
|
|
11
|
-
```py
|
|
12
|
-
|
|
13
|
-
import flet as ft
|
|
14
|
-
|
|
15
|
-
import flet_audio_recorder as far
|
|
16
|
-
|
|
17
|
-
async def main(page: ft.Page):
|
|
18
|
-
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
|
|
19
|
-
page.appbar = ft.AppBar(title=ft.Text("Audio Recorder"), center_title=True)
|
|
20
|
-
|
|
21
|
-
path = "test-audio-file.wav"
|
|
22
|
-
|
|
23
|
-
async def handle_start_recording(e):
|
|
24
|
-
print(f"StartRecording: {path}")
|
|
25
|
-
await audio_rec.start_recording_async(path)
|
|
26
|
-
|
|
27
|
-
async def handle_stop_recording(e):
|
|
28
|
-
output_path = await audio_rec.stop_recording_async()
|
|
29
|
-
print(f"StopRecording: {output_path}")
|
|
30
|
-
if page.web and output_path is not None:
|
|
31
|
-
await page.launch_url_async(output_path)
|
|
32
|
-
|
|
33
|
-
async def handle_list_devices(e):
|
|
34
|
-
devices = await audio_rec.get_input_devices_async()
|
|
35
|
-
print(devices)
|
|
36
|
-
|
|
37
|
-
async def handle_has_permission(e):
|
|
38
|
-
try:
|
|
39
|
-
print(f"HasPermission: {await audio_rec.has_permission_async()}")
|
|
40
|
-
except Exception as e:
|
|
41
|
-
print(e)
|
|
42
|
-
|
|
43
|
-
async def handle_pause(e):
|
|
44
|
-
print(f"isRecording: {await audio_rec.is_recording_async()}")
|
|
45
|
-
if await audio_rec.is_recording_async():
|
|
46
|
-
await audio_rec.pause_recording_async()
|
|
47
|
-
|
|
48
|
-
async def handle_resume(e):
|
|
49
|
-
print(f"isPaused: {await audio_rec.is_paused_async()}")
|
|
50
|
-
if await audio_rec.is_paused_async():
|
|
51
|
-
await audio_rec.resume_recording_async()
|
|
52
|
-
|
|
53
|
-
async def handle_audio_encoding_test(e):
|
|
54
|
-
for i in list(far.AudioEncoder):
|
|
55
|
-
print(f"{i}: {await audio_rec.is_supported_encoder_async(i)}")
|
|
56
|
-
|
|
57
|
-
async def handle_state_change(e):
|
|
58
|
-
print(f"State Changed: {e.data}")
|
|
59
|
-
|
|
60
|
-
audio_rec = far.AudioRecorder(
|
|
61
|
-
audio_encoder=far.AudioEncoder.WAV,
|
|
62
|
-
on_state_changed=handle_state_change,
|
|
63
|
-
)
|
|
64
|
-
page.overlay.append(audio_rec)
|
|
65
|
-
await page.update_async()
|
|
66
|
-
|
|
67
|
-
await page.add_async(
|
|
68
|
-
ft.ElevatedButton("Start Audio Recorder", on_click=handle_start_recording),
|
|
69
|
-
ft.ElevatedButton("Stop Audio Recorder", on_click=handle_stop_recording),
|
|
70
|
-
ft.ElevatedButton("List Devices", on_click=handle_list_devices),
|
|
71
|
-
ft.ElevatedButton("Pause Recording", on_click=handle_pause),
|
|
72
|
-
ft.ElevatedButton("Resume Recording", on_click=handle_resume),
|
|
73
|
-
ft.ElevatedButton("Test AudioEncodings", on_click=handle_audio_encoding_test),
|
|
74
|
-
ft.ElevatedButton("Has Permission", on_click=handle_has_permission),
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
ft.app(main)
|
|
79
|
-
```
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: flet-audio-recorder
|
|
3
|
-
Version: 0.2.0.dev17
|
|
4
|
-
Summary: AudioRecorder control for Flet
|
|
5
|
-
Author-email: Flet contributors <hello@flet.dev>
|
|
6
|
-
Project-URL: Homepage, https://flet.dev
|
|
7
|
-
Project-URL: Documentation, https://flet.dev/docs/controls/audiorecorder
|
|
8
|
-
Project-URL: Repository, https://github.com/flet-dev/flet-audio-recorder
|
|
9
|
-
Project-URL: Issues, https://github.com/flet-dev/flet-audio-recorder/issues
|
|
10
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
-
Requires-Python: >=3.8
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
Requires-Dist: flet>=0.25.2
|
|
14
|
-
|
|
15
|
-
# AudioRecorder control for Flet
|
|
16
|
-
|
|
17
|
-
`AudioRecorder` control for Flet.
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
Add `flet-audio-recorder` as dependency (`pyproject.toml` or `requirements.txt`) to your Flet project.
|
|
22
|
-
|
|
23
|
-
## Example
|
|
24
|
-
|
|
25
|
-
```py
|
|
26
|
-
|
|
27
|
-
import flet as ft
|
|
28
|
-
|
|
29
|
-
import flet_audio_recorder as far
|
|
30
|
-
|
|
31
|
-
async def main(page: ft.Page):
|
|
32
|
-
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
|
|
33
|
-
page.appbar = ft.AppBar(title=ft.Text("Audio Recorder"), center_title=True)
|
|
34
|
-
|
|
35
|
-
path = "test-audio-file.wav"
|
|
36
|
-
|
|
37
|
-
async def handle_start_recording(e):
|
|
38
|
-
print(f"StartRecording: {path}")
|
|
39
|
-
await audio_rec.start_recording_async(path)
|
|
40
|
-
|
|
41
|
-
async def handle_stop_recording(e):
|
|
42
|
-
output_path = await audio_rec.stop_recording_async()
|
|
43
|
-
print(f"StopRecording: {output_path}")
|
|
44
|
-
if page.web and output_path is not None:
|
|
45
|
-
await page.launch_url_async(output_path)
|
|
46
|
-
|
|
47
|
-
async def handle_list_devices(e):
|
|
48
|
-
devices = await audio_rec.get_input_devices_async()
|
|
49
|
-
print(devices)
|
|
50
|
-
|
|
51
|
-
async def handle_has_permission(e):
|
|
52
|
-
try:
|
|
53
|
-
print(f"HasPermission: {await audio_rec.has_permission_async()}")
|
|
54
|
-
except Exception as e:
|
|
55
|
-
print(e)
|
|
56
|
-
|
|
57
|
-
async def handle_pause(e):
|
|
58
|
-
print(f"isRecording: {await audio_rec.is_recording_async()}")
|
|
59
|
-
if await audio_rec.is_recording_async():
|
|
60
|
-
await audio_rec.pause_recording_async()
|
|
61
|
-
|
|
62
|
-
async def handle_resume(e):
|
|
63
|
-
print(f"isPaused: {await audio_rec.is_paused_async()}")
|
|
64
|
-
if await audio_rec.is_paused_async():
|
|
65
|
-
await audio_rec.resume_recording_async()
|
|
66
|
-
|
|
67
|
-
async def handle_audio_encoding_test(e):
|
|
68
|
-
for i in list(far.AudioEncoder):
|
|
69
|
-
print(f"{i}: {await audio_rec.is_supported_encoder_async(i)}")
|
|
70
|
-
|
|
71
|
-
async def handle_state_change(e):
|
|
72
|
-
print(f"State Changed: {e.data}")
|
|
73
|
-
|
|
74
|
-
audio_rec = far.AudioRecorder(
|
|
75
|
-
audio_encoder=far.AudioEncoder.WAV,
|
|
76
|
-
on_state_changed=handle_state_change,
|
|
77
|
-
)
|
|
78
|
-
page.overlay.append(audio_rec)
|
|
79
|
-
await page.update_async()
|
|
80
|
-
|
|
81
|
-
await page.add_async(
|
|
82
|
-
ft.ElevatedButton("Start Audio Recorder", on_click=handle_start_recording),
|
|
83
|
-
ft.ElevatedButton("Stop Audio Recorder", on_click=handle_stop_recording),
|
|
84
|
-
ft.ElevatedButton("List Devices", on_click=handle_list_devices),
|
|
85
|
-
ft.ElevatedButton("Pause Recording", on_click=handle_pause),
|
|
86
|
-
ft.ElevatedButton("Resume Recording", on_click=handle_resume),
|
|
87
|
-
ft.ElevatedButton("Test AudioEncodings", on_click=handle_audio_encoding_test),
|
|
88
|
-
ft.ElevatedButton("Has Permission", on_click=handle_has_permission),
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
ft.app(main)
|
|
93
|
-
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|