audio.mdx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ---
  2. sidebar_position: 3
  3. slug: /audio
  4. ---
  5. import Tabs from '@theme/Tabs';
  6. import TabItem from '@theme/TabItem';
  7. import UppyCdnExample from '/src/components/UppyCdnExample';
  8. # Audio
  9. The `@uppy/audio` plugin lets you record audio using a built-in or external
  10. microphone, or any other audio device, on desktop and mobile. The UI shows real
  11. time sound wavelength when recording.
  12. :::tip
  13. [Try out the live example](/examples) or take it for a spin in
  14. [StackBlitz](https://stackblitz.com/edit/vitejs-vite-zaqyaf?file=main.js).
  15. :::
  16. ## When should I use this?
  17. When you want users to record audio on their computer.
  18. ## Install
  19. <Tabs>
  20. <TabItem value="npm" label="NPM" default>
  21. ```shell
  22. npm install @uppy/audio
  23. ```
  24. </TabItem>
  25. <TabItem value="yarn" label="Yarn">
  26. ```shell
  27. yarn add @uppy/audio
  28. ```
  29. </TabItem>
  30. <TabItem value="cdn" label="CDN">
  31. <UppyCdnExample>
  32. {`
  33. import { Uppy, Dashboard, Audio } from "{{UPPY_JS_URL}}"
  34. const uppy = new Uppy()
  35. uppy.use(Dashboard, { inline: true, target: 'body' })
  36. uppy.use(Audio, { target: Uppy.Dashboard })
  37. `}
  38. </UppyCdnExample>
  39. </TabItem>
  40. </Tabs>
  41. ## Use
  42. ```js {3,7,11} showLineNumbers
  43. import Uppy from '@uppy/core';
  44. import Dashboard from '@uppy/dashboard';
  45. import Audio from '@uppy/audio';
  46. import '@uppy/core/dist/style.min.css';
  47. import '@uppy/dashboard/dist/style.min.css';
  48. import '@uppy/audio/dist/style.min.css';
  49. new Uppy()
  50. .use(Dashboard, { inline: true, target: 'body' })
  51. .use(Audio, { target: Dashboard });
  52. ```
  53. ### API
  54. ### Options
  55. #### `id`
  56. A unique identifier for this plugin (`string`, default: `'audio'`).
  57. #### `title`
  58. Configures the title / name shown in the UI, for instance, on Dashboard tabs
  59. (`string`, default: `'Audio'`).
  60. #### `target`
  61. DOM element, CSS selector, or plugin to place the audio into (`string` or
  62. `Element`, default: `null`).
  63. #### `showAudioSourceDropdown`
  64. Configures whether to show a dropdown to select audio device (`boolean`,
  65. default: `false`).
  66. #### `locale`
  67. ```js
  68. export default {
  69. strings: {
  70. pluginNameAudio: 'Audio',
  71. // Used as the label for the button that starts an audio recording.
  72. // This is not visibly rendered but is picked up by screen readers.
  73. startAudioRecording: 'Begin audio recording',
  74. // Used as the label for the button that stops an audio recording.
  75. // This is not visibly rendered but is picked up by screen readers.
  76. stopAudioRecording: 'Stop audio recording',
  77. // Title on the “allow access” screen
  78. allowAudioAccessTitle: 'Please allow access to your microphone',
  79. // Description on the “allow access” screen
  80. allowAudioAccessDescription:
  81. 'In order to record audio, please allow microphone access for this site.',
  82. // Title on the “device not available” screen
  83. noAudioTitle: 'Microphone Not Available',
  84. // Description on the “device not available” screen
  85. noAudioDescription:
  86. 'In order to record audio, please connect a microphone or another audio input device',
  87. // Message about file size will be shown in an Informer bubble
  88. recordingStoppedMaxSize:
  89. 'Recording stopped because the file size is about to exceed the limit',
  90. // Used as the label for the counter that shows recording length (`1:25`).
  91. // This is not visibly rendered but is picked up by screen readers.
  92. recordingLength: 'Recording length %{recording_length}',
  93. // Used as the label for the submit checkmark button.
  94. // This is not visibly rendered but is picked up by screen readers.
  95. submitRecordedFile: 'Submit recorded file',
  96. // Used as the label for the discard cross button.
  97. // This is not visibly rendered but is picked up by screen readers.
  98. discardRecordedFile: 'Discard recorded file',
  99. },
  100. };
  101. ```