Package: usttc
USTTC (Unified Speech-to-Text Client)This project provides a simple and unified client wrapper
for multipleSpeech-to-test (STT)providers on the basic use cases,
and gives users an easy way to switch and test among different providers.BackgroundThe accuracy of Speech-to-text (STT) improved significantly during the past few years.
There are a lot of cloud STT providers on the market, including some big players like Google and AWS,
and a few ambitious new providers like Voicegain.ai and Assembly.ai.As a Speech Recognition Scientist, I have reviewed many providers in the last few years,
and I have noticed that each provider has its own unique features.
However, the majority of users do not necessarily need those additional features,
especially in the early testing stage.
Their requirements are very simple and basic -- getting an accurate transcript of the provided audio.Regarding my personal background, I am an Senior AI Scientist at Voicegain (specializing in Speech Recognition),
but this repository, USTTC, is a personal project, and I intend to work on it without any bias.
As mentioned, the goal of this project is to enable more people in the community to explore and test STT
without too much trouble dealing with varied providers, APIs, and documentation.InstallationPlease ensure that you haveffmpeginstalled before install USTTC.You can install the module using the Python Package Index using the command below.pip install usttcDetermine which STT providers to testCurrently, USTTC supports the following 6 STT providers. We are going to include a few more providers later on.Google STTAWS TranscribeVoicegain.aiRev.aiassembly.aideepgramThese six providers are included because they all have comparable accuracy,
reasonable complete features, and simple-to-use client SDKs. Now you need to decide which providers you want to test.
This is truly an overwhelming task, because there is no single right answer.
Each provider has unique strengths and weaknesses, as well as its own unique pricing strategy.
If you don't know which one is best for your application,
we suggest you test all of them on your own audio samples to get a sense. Fortunately,
USTTC makes it very easy to test multiple providers using (almost) the same code,
which is also the original intention of USTTC.The following table shows the price of each provider, so that you can also choose based on your budget.Provider Price Details[1]$ per minute[2]Free Tier per monthFree CreditsMinimum per request charge[3]IncrementsGoogle STT$0.036060 minutes8,333 minutes ($300)[4]15 seconds15 secondsAWS Transcribe$0.024060 minutes[5]No15 seconds1 secondVoicegain.ai$0.0095No5,263 minutes ($50)1 second1 secondRev.ai$0.0350No300 minutes15 seconds15 secondsAssembly.ai$0.0150180 minutesNo1 second1 secondDeepgram$0.0125No12,000 minutes ($150)Not clearNot clear[1]: The price may change. Please check the pricing page for each provider[2]: This is the pay-as-you-go price. All providers provide discounts for high volumes[3]: You need to consider this if the average audio duration is shorter than 15s in your application[4]: The Google Cloud Free credits are distributed across all cloud services and are only valid for the first 90 days[5]: The AWS Free Tier is only available for the first 12 monthsCreate account on selected STT providersOnce you decide which providers to test, you can create an account with them by following the steps below.Google STTSign up Google Cloud Platform.https://console.cloud.google.com/getting-startedEnableGoogle Cloud Speech API.https://cloud.google.com/endpoints/docs/openapi/enable-apiCreate a storage bucket. You can use the default setting.https://cloud.google.com/storage/docs/creating-bucketsCreate a service account. AddCloud Speech ClientandStorage Object Admintwo roles.https://cloud.google.com/iam/docs/creating-managing-service-accounts#iam-service-accounts-create-consoleCreate newJSON keyfor the service account you created.https://cloud.google.com/iam/docs/creating-managing-service-account-keysfrom usttc import AsrClientFactory, AsrProvider

asr_client = AsrClientFactory.get_client_from_key_file(
    asr_provider=AsrProvider.GOOGLE,
    filename="<YOUR_GOOGLE_CLOUD_JSON_KEY_FILE_PATH>",
    google_storage_bucket="<YOUR_GOOGLE_STORAGE_BUCKET_NAME>"
)AWS TranscribeSign up for AWS.https://portal.aws.amazon.com/billing/signup#/startCreate a S3 bucket. You can use the default setting. Please take a note of theregionof your S3 bucket.https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.htmlCreate aUser Group. AttachAmazonS3FullAccessandAmazonTranscribeFullAccesspermission to the group.https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups_create.htmlAdd aUserto the createdUser Group. Get user'saccess key IDandsecret access key.https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_consolefrom usttc import AsrClientFactory, AsrProvider

asr_client = AsrClientFactory.get_client_from_key(
    asr_provider=AsrProvider.AMAZON_AWS,
    key="<YOUR_AWS_USER_ACCESS_KEY_ID>",
    aws_secret_access_key="<YOUR_AWS_USER_SECRET_ACCESS_KEY>",
    region_name='<YOUR_S3_BUCKET_REGION>',
    s3_bucket='<YOUR_S3_BUCKET_NAME>'
)Voicegain.aiSign up.https://console.voicegain.ai/signupGenerateJWT Token.https://support.voicegain.ai/hc/en-us/articles/360028023691-JWT-Authenticationfrom usttc import AsrClientFactory, AsrProvider

asr_client = AsrClientFactory.get_client_from_key(
    asr_provider=AsrProvider.VOICEGAIN,
    key="<YOUR_VOICEGAIN_JWT_TOKEN>"
)Rev.aiSign up.https://www.rev.ai/auth/signupGenerateAccess Token.https://www.rev.ai/access_tokenfrom usttc import AsrClientFactory, AsrProvider

asr_client = AsrClientFactory.get_client_from_key(
    asr_provider=AsrProvider.REV,
    key="<YOUR_REV_ACCESS_TOKEN>"
)Assembly.aiSign up.https://app.assemblyai.com/signupGetAPI Keyon your account page.https://app.assemblyai.com/accountfrom usttc import AsrClientFactory, AsrProvider

asr_client = AsrClientFactory.get_client_from_key(
    asr_provider=AsrProvider.ASSEMBLY_AI,
    key="<YOUR_ASSEMBLY_AI_API_KEY>"
)DeepgramSign up.https://console.deepgram.com/signupCreateAPI Keyfrom the dashboardfrom usttc import AsrClientFactory, AsrProvider

asr_client = AsrClientFactory.get_client_from_key(
    asr_provider=AsrProvider.DEEPGRAM,
    key="<YOUR_DEEPGRAM_API_KEY>"
)UsageBoth pre-recorded audio files and real-time audio streams can be transcribed with USTTC.Transcribe Pre-Recorded AudioUsing USTTC, it's super easy to transcribe your audio file in (almost)any format.Hereis an end-to-end example of an .wav audio as the input.from usttc.audio import AudioFile

audio = AudioFile(file_path="<YOUR_AUDIO_FILE_PATH>")
result = asr_client.recognize(audio)
print(result.transcript)Multiple SpeakersAn audio file can contain multiple speakers in two ways.Multi-channel audio: Each channel has one speaker. (We only support stereo audio). In this case, you need to configureseparate_speaker_per_channel(example)Mono audio: All speakers are mixed on the same channel. In this case, you need to configurediarization(example)Please note here:If your audio is stereo but both channels have the same content, you shouldNOTconfigureseparate_speaker_per_channel.DO NOTuse diarization if speakers are already separated by channel.Compare transcription resultsTo compare the results from multiple recognizers and know which one is more accurate for the application, I'll normally start by reviewing a few results and getting a sense of the weaknesses and strengths of each recognizer. Sometimes, after I see a few examples, I can easily tell for a specific project which recognizers work and which do not.If you want to compare the results in a more scientific manner, you can prepare the gold standard reference and calculateWord Error Rate (WER)of the results from each STT provider. However, calculating WER is not trivial, because we don't want to penalize a recognizer if the difference (its result vs. the gold reference) is just the punctuation and capitalization. Moreover, for a digit, it's both acceptable no matter whether using digit-format or spelled-out format.transcribe-compare packageVoicegain.aiprovides a python package calledtranscribe-compareto help you calculate WER (and do more than that).
It solves many issues when calculating WER, including punctuation, capitalization, and digits mentioned above.
You can install the module using the Python Package Index using the command below.pip install transcribe-compareWe provide a simpleexampleof usingUSTTCandtranscribe-comparetogether.
You can also check theirGitHub pagefor more examples of advanced use cases.Ensemble[This feature will be available soon]After you compare the results from multiple recognizers, you might realize that none of them is perfect (it is a cold and brute reality). Different STT providers might make mistakes in different places. If your budget allows, you can run multiple recognizers at the same time and get higher accuracy by ensembling their results. This feature is on our roadmap.Transcribe Audio Stream[This feature will be available soon]In some applications (e.g. real-time), it's important to stream the audio to the recognizer
and get the result simultaneously.
All the STT providers that USTTC selected have the streaming feature.
The streaming wrapper will be available soon.