# Speech-To-Text With Go In 5 Minutes | Speech Recognition Tutorial In Go

## Метаданные

- **Канал:** AssemblyAI
- **YouTube:** https://www.youtube.com/watch?v=rT7QSvgUhwc
- **Дата:** 25.02.2022
- **Длительность:** 4:57
- **Просмотры:** 4,218
- **Источник:** https://ekstraktznaniy.ru/video/13189

## Описание

Learn how to do Speech-to-Text conversion in Go in 5 minutes! We use AssemblyAI API and a simple HTTP client to do this!

Get your Free Token for AssemblyAI Speech-To-Text API 👇https://www.assemblyai.com/?utm_source=youtube&utm_medium=referral&utm_campaign=yt_pat_17

The example video: https://youtu.be/9_RxaeN0FGw

Code: https://github.com/AssemblyAI/speech-to-text-golang-example

▬▬▬▬▬▬▬▬▬▬▬▬ CONNECT ▬▬▬▬▬▬▬▬▬▬▬▬

🖥️ Website: https://www.assemblyai.com
🐦 Twitter: https://twitter.com/AssemblyAI
🦾 Discord: https://discord.gg/Cd8MyVJAXd
▶️  Subscribe: https://www.youtube.com/c/AssemblyAI?sub_confirmation=1
🔥 We're hiring! Check our open roles: https://www.assemblyai.com/careers

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Speech recognition in Go
Speech recognition in Golang
Speech to Text in Golang
Speech to Text in Go
Speech-to-Text in Golang
Speech-to-Text in Go

#Go

## Транскрипт

### Intro []

hi everyone i'm patrick and in this video i show you how you can do speech-to-text conversion in go with only a few simple steps so for this we use the speech-to-text api from assembly ai which is really easy to set up so we only need to send a few simple http requests so let's do this and for this i prepared one audio file which is by the way corresponding to this video so i just downloaded this with a youtube downloader and now i have it here and you can try this for yourself and compare the results and they are pretty accurate so i recommend that you just follow my tutorial and try this so let's get started so as first step we need to upload a file and if you've already hosted this somewhere in the web then you can skip this step

### Setup [0:45]

but now i show you how to do this so first we import a few packages so the most important is the http package to send the get and post requests then we also need json to work with json data and a few more to load our data and also for logging then we create one function main then of course we need an api key and we need the upload url so this is at assemblyai. com and then the upload endpoint of our api and yeah you can sign up for free and then you can grab your api token in the dashboard and this is all you need then we read our local file so here i've prepared one audio file so i read this here and check for errors and then i set up a http client and then we have to set some headers so um first we create a new post request to the upload url and in here we read the audio data here with this dot new buffer method then we set the header so here we have to set the authorization and i'll use our api key then we execute client do the request and we get a result and then again we can check for the error and then as last thing we want to decode the json data and store it in a map and then we can access the different fields so in this case we want to access the fields upload url

### Transcription [2:22]

url and this is all that we need so now we can run we can say go run and then the um file name so this is upload. go and this should work all right this worked so here we have our upload url so now we can copy this and use this for the next set now a second step we start the transcription so here we put in the audio url that we printed here then we here we need a transcript url so this is the transcript endpoint of the assembly ai api and now we need to prepare json data so the json data has to contain the audio url key and as value we use this audio url and then again here we set up our http client with a post request and we have to set up the header with the authorization and now here we also have to set the content type which is application json and then we do the exact same thing so we execute our request and then we decode the json and in this case we want to access and print the id of the transcribed audio so let's run this so let's say go run and in this case i call this transcribe dot go and now we have the transcription id so we can copy this and then use this for the final step and the final step is

### Result [3:48]

very similar so now we simply have to get the result so we create a new endpoint which contains the base transcript url plus a slash and then the transcript id that we just grabbed here and then again we set up a client and this time we use a get request and then again we use the content type and the authorization and execute this and then we can again decode the result and have json data now as a map and then we can check the status field and if this is completed then we can access the text field and now this is the transcription of our audio file so now let's say go run and then paul dot go and let's print the text and here we have it so now you can watch the youtube video and follow this tutorial and then compare this and see for yourself how good this works and yeah i think this is really simple to set up it only takes a few minutes and yeah i hope you learned something new and if you enjoyed this video then please hit the like button and then i hope to see you in the next video bye
