The following code to take that CLI argument and assign it to a variable called audioUrl. We will need to pass the hosted audio file URL as a command-line argument when we run the application. We also define the AssemblyAI API endpoint as url. The above code will import the two packages that we added earlier, dotenv and fetch. Copy and paste the following code into this file: import 'dotenv/config' Open the upload.js that we created earlier in your code editor. This will allow you to use ES Modules, which we will require for this project. Start now for free! Start Now Uploading an audio file to the AssemblyAI Transcription APIīefore starting, add "type": "module" to your package.json file. Want to play around with our Speech-to-Text API? You can find your API key in the AssemblyAI dashboard and add it as the value to the above variable. env file in your code editor and add an environment variable to store your AssemblyAI API Key. We will also use the Fetch API to make our REST call, so make sure to install that too: npm i node-fetch -save You can install it with the following command: npm i dotenv -save If you don’t already have it installed, we will need the node package dotenv to manage our AssemblyAI API key. envĪnd if using macOS or Linux: touch upload.js & touch download.js & touch. If using Windows: New-Item upload.js, download.js. Navigate into it and initialise a new Node.js project: mkdir transcribeĬreate three new files inside your new transcribe directory: Getting your development environment setupĬreate a new directory on your computer using your favourite command-line program, such as Terminal or Powershell. If you would like to see the completed code project, it is available at this GitHub repository. Next, we’ll pass the transcription ID as an argument to a second function that will go and fetch our transcription and print it to the screen! Prerequisites Then, we’ll print the response from AssemblyAI on the command-line as well as the ID of our transcription. This second function will send an HTTP request to the AssemblyAI speech-to-text transcription API. We will first pass a URL of an audio recording as an argument to an upload function. In this post, we will make a basic node.js command-line interface app (often abbreviated to CLI app). ![]() Getting started with a new technology can be daunting, but we’re going to break down speech-to-text transcription with node.js to make it easier! ![]() Senior API Support Engineer at AssemblyAI
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |