| Method Signatures and Parameters | |
Jt.audioInput(String label) | label (String) A short label explaining to the user what this audio input widget is for. Markdown is supported, see |
| Chainable builder methods | |
sampleRate(Integer sampleRate) | The target sample rate for the audio recording in Hz. This defaults to 16000 Hz, which is optimal for speech recognition.
The following sample rates are supported: 8000, 11025, 16000, 22050, 24000, 32000, 44100, or 48000.
If this is set to |
help(String help) | A tooltip that gets displayed next to the text. If this is |
disabled(boolean disabled) | Disable the file uploader if set to true. When disabled, users cannot interact with the widget. |
onChange(function.Consumer<JtUploadedFile> onChange) | An optional callback invoked when the file uploader's value changes. |
labelVisibility(JtComponent.LabelVisibility labelVisibility) | The visibility of the label. The default is |
width(String width) | The width of the element. This can be one of the following:
|
width(int widthPixels) | The width of the text element in pixels. The element will have a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. |
key(String key) | A string to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key. |
Only applies to input widgets that have a provided | |
use() | Put the widget in the app, in the |
use(JtContainer container) | Put the widget in the app, in the provided container. |
| Returns after .use() | |
(JtUploadedFile) | The current JtUploadedFile value of the component. |
Examples
Record a voice message and play it back. The default sample rate of 16000 Hz is optimal for speech recognition.
import io.javelit.core.Jt;
public class AudioInputApp {
public static void main(String[] args) {
var recording = Jt.audioInput("Record a voice message").use();
if (recording != null) {
Jt.audio(recording).use();
}
}
}
Record high-fidelity audio and play it back. Higher sample rates can create higher-quality, larger audio files.
This might require a nicer microphone to fully appreciate the difference.
import io.javelit.core.Jt;
public class HighQualityAudioInputApp {
public static void main(String[] args) {
var recording = Jt.audioInput("Record high quality audio").sampleRate(48000).use();
if (recording != null) {
Jt.audio(recording).use();
}
}
}
Still have questions?
Go to our discussions forum for helpful information and advice from Javelit experts.