audio.mdx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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)
  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().use(Dashboard, { inline: true, target: 'body' }).use(Audio);
  50. ```
  51. ### API
  52. ### Options
  53. #### `id`
  54. A unique identifier for this plugin (`string`, default: `'audio'`).
  55. #### `title`
  56. Configures the title / name shown in the UI, for instance, on Dashboard tabs
  57. (`string`, default: `'Audio'`).
  58. #### `target`
  59. DOM element, CSS selector, or plugin to place the drag and drop area into
  60. (`string`, `Element`, `Function`, or `UIPlugin`, default:
  61. [`Dashboard`](/docs/dashboard)).
  62. #### `showAudioSourceDropdown`
  63. Configures whether to show a dropdown to select audio device (`boolean`,
  64. default: `false`).
  65. #### `locale`
  66. ```js
  67. export default {
  68. strings: {
  69. pluginNameAudio: 'Audio',
  70. // Used as the label for the button that starts an audio recording.
  71. // This is not visibly rendered but is picked up by screen readers.
  72. startAudioRecording: 'Begin audio recording',
  73. // Used as the label for the button that stops an audio recording.
  74. // This is not visibly rendered but is picked up by screen readers.
  75. stopAudioRecording: 'Stop audio recording',
  76. // Title on the “allow access” screen
  77. allowAudioAccessTitle: 'Please allow access to your microphone',
  78. // Description on the “allow access” screen
  79. allowAudioAccessDescription:
  80. 'In order to record audio, please allow microphone access for this site.',
  81. // Title on the “device not available” screen
  82. noAudioTitle: 'Microphone Not Available',
  83. // Description on the “device not available” screen
  84. noAudioDescription:
  85. 'In order to record audio, please connect a microphone or another audio input device',
  86. // Message about file size will be shown in an Informer bubble
  87. recordingStoppedMaxSize:
  88. 'Recording stopped because the file size is about to exceed the limit',
  89. // Used as the label for the counter that shows recording length (`1:25`).
  90. // This is not visibly rendered but is picked up by screen readers.
  91. recordingLength: 'Recording length %{recording_length}',
  92. // Used as the label for the submit checkmark button.
  93. // This is not visibly rendered but is picked up by screen readers.
  94. submitRecordedFile: 'Submit recorded file',
  95. // Used as the label for the discard cross button.
  96. // This is not visibly rendered but is picked up by screen readers.
  97. discardRecordedFile: 'Discard recorded file',
  98. },
  99. };
  100. ```