Code Monkey home page Code Monkey logo

vue-audio-tapir's Introduction

vue-audio-tapir npm npm Snyk Vulnerabilities for GitHub Repo


Audio recorder component for Vue.js 3. It enables to record, play and send audio messages to a server. There is a corresponding serverless backend function called audio-tapir-function. You can use both in combination to send you an email with the recorded audio message.

Demo

Demo page of Audio Tapir, you can record and play audio, but submitting is disabled.

Use Case

The most popular use case of vue-audio-tapir is to deliver an audio contact message directly from a website to your email inbox.

Architecture Overview

The developer includes the vue-audio-tapir component in his Vue 3 website. When the user of the website wants to leave a voice message, he records his message and submits it. Vue-audio-tapir contacts the backend server, a Netlify serverless function and uploads the audio data. The serverless backend function sends the audio data to an email address using the email service Sendgrid. Finally the email with the voice message arrives at the destination, probably the email application of the website owner.

Installation

In a Vue 3 application install with:

npm i vue-audio-tapir --save

or

yarn add vue-audio-tapir --save

Example Usage

<template>
  <tapir-widget :time="2" backendEndpoint="https://your-endpoint.com/.netlify/functions/audio-message" 
                buttonColor="green"/>
</template>

<script>
import TapirWidget from 'vue-audio-tapir';
import 'vue-audio-tapir/dist/vue-audio-tapir.css';

export default {
  name: 'App',
  components: {
    TapirWidget,
  }
}
</script>

More Example

In the examples folder you can find a Vue CLI example and a Vite example.

Properties

Name Type Description
time Number Maximum recording time in minutes
bitRate Number Bit rate of recording
sampleRate Number Sample rate of recording
backendEndpoint String URL of the service that receives the data as POST
buttonColor String Color code of the buttons for theming
afterRecording Function Callback function when recording is finished.
successfulUpload Function Callback function that is called when data is uploaded successfully.
failedUpload Function Callback function that is called when upload failed.
customUpload Function Custom upload function that expects the audio blob as parameter. Returns true when successful, false when error.

The data sent to the server is encoded in the WAV format.

Local Development

If you need to run audio-tapir locally, run:

npm run serve

Building

If you want to build audio-tapir locally, run:

npm run build

Compatibility

Successfully tested with applications that use Vue 3, vue-cli and vite.

Dependencies

More Information

Follow me on Mastodon for updates: @td8

Your can read more about the Audio Tapir project on my blog:

https://www.tderflinger.com/en/easily-receive-audio-messages-from-users

Further Reading

References

This project has been inspired by vue-audio-recorder by Gennady Grishkovtsov.

License

MIT License

vue-audio-tapir's People

Contributors

tderflinger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-audio-tapir's Issues

Module Loader error

Hey, I keep running into this error whenever I attempt to build.

Any idea how to fix it?

image

Please add custom upload method

thanks for this plugin

Please add custom upload method or pass audio file to "afterRecording" to add custom upload functonality

Translating to persian

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/vue-audio-tapir/src/components/TapirWidget.vue b/node_modules/vue-audio-tapir/src/components/TapirWidget.vue
index d682a58..4ec01a9 100644
--- a/node_modules/vue-audio-tapir/src/components/TapirWidget.vue
+++ b/node_modules/vue-audio-tapir/src/components/TapirWidget.vue
@@ -1,6 +1,6 @@
 <template>
   <div class="text-center font-sans w-96 mx-auto rounded-lg shadow-lg border-solid border-2 p-8">
-    <h2 class="font-bold text-2xl">Record Audio Message</h2>
+    <h2 class="font-bold text-2xl">ضبط فایل صوتی</h2>
     <div>
       <icon-button
         :style="{ 'border-color': buttonColor }"
@@ -26,7 +26,7 @@
         Your browser does not support the
         <code>audio</code> element.
       </audio>
-      <figcaption class="text-sm mt-2">Listen to your recording before submitting.</figcaption>
+      <figcaption class="text-sm mt-2">به ویس ضبط شده گوش دهید</figcaption>
     </figure>
     <submit-button @submit="sendData" :color="buttonColor" />
   </div>
@@ -39,7 +39,7 @@ import Recorder from "../lib/recorder";
 import convertTimeMMSS from "../lib/utils";
 import "../styles/app.css";
 
-const INSTRUCTION_MESSAGE = "Click icon to start recording message.";
+const INSTRUCTION_MESSAGE = "بر روی آیکون کلیک کنید تا ضبط کردن آغاز شود";
 const INSTRUCTION_MESSAGE_STOP = "Click icon again to stop recording.";
 const ERROR_MESSAGE = "Failed to use microphone. Please refresh and try again and permit the use of a microphone.";
 const SUCCESS_MESSAGE = "Successfully recorded message!";

This issue body was partially generated by patch-package.

Vue 3 project getting this error on install

npm i vue-audio-tapir --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/vue
npm ERR! vue@"^3.3.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"3.2.39" from [email protected]
npm ERR! node_modules/vue-audio-tapir
npm ERR! vue-audio-tapir@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

ReferenceError: Lame is not defined

vue-router.js?v=e213c068:2226 ReferenceError: Lame is not defined
at Object.db3f (vue-audio-tapir.js?v=e213c068:4949:14)
at n (vue-audio-tapir.js?v=e213c068:23:24)
at Module.fb15 (vue-audio-tapir.js?v=e213c068:6546:17)
at n (vue-audio-tapir.js?v=e213c068:23:24)
at 00ee (vue-audio-tapir.js?v=e213c068:50:22)
at vue-audio-tapir.js?v=e213c068:51:8
at vue-audio-tapir.js?v=e213c068:15:84
at node_modules/vue-audio-tapir/dist/vue-audio-tapir.umd.min.js (vue-audio-tapir.js?v=e213c068:16:7)
at __require (chunk-WNHHNXF2.js?v=e213c068:40:50)
at vue-audio-tapir.js?v=e213c068:6740:31


<script setup> import TapirWidget from 'vue-audio-tapir'; import 'vue-audio-tapir/dist/vue-audio-tapir.css'; </script> Audio
      <v-row>
        <v-col cols="12" md="6">
          <div>             
            <TapirWidget :time="2" backendEndpoint="https://your-endpoint.com/.netlify/functions/audio-message" 
            buttonColor="green"/>
          </div>
        </v-col>
      </v-row>
    </SgBaseCard>
  </v-col>
</v-row>
<style lang="scss" scoped> </style>
"vue": "^3.2.33",
"vue-audio-tapir": "^1.2.0",
"vite": "^2.9.5",

├─ [email protected]
│ ├─ [email protected]
│ └─ [email protected]

How can I get the file?

How can I get the file?
Is there a way to just generate and get the file? without showing the option to listen or submit?

Audio recording makes voice sound deeper

With the default options I'm noticing most recorded clips make the voice sound deeper than usual almost like it was playing a bit slower. Does anyone know if there's a way to fix this? I played with the options but wasn't noticing a major difference

Parameterize labels

Hi Thomas, thanks for sharing this component!

I needed to override some of the labels that are currently hard-coded (e.g. submit button label, instructions, etc.) I created a fork and made the changes. You can see them here:

main...antun:vue-audio-tapir:main

Is it OK if I submit a PR to your repo for these changes? I made the default texts the same as you currently have - it's just they can be overridden now. I imagine this would be useful to others.

(I also added some notes to the README file - I found I had to install Vue and a couple of other dependencies for it to work - maybe you have them globally installed?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.