Using Restfull API of Farsava Deep learning Automatic Speech Recognition to convert Persian Speech…

Original article was published by mobin shaterian on Deep Learning on Medium


Using Restfull API of Farsava Deep learning Automatic Speech Recognition to convert Persian Speech to Text in PHP

In this article,I want to use API Restfull of Farsava ASR in Laravel to convert speech to text.

Speech to text with deep Learning is popular today and used for many purposes, such as call center, subtitle making.

Farsava is Persian convertor of Persian Speech to Text.

Before implement using Farsava asr, let’s check asr performance in the link below. for using this web application you need to have MTN Irancell or Hamrahaval Simcard.

let’s impeliment API Connection

Get API Key

For getting an API key it’s necessary to visit the below link.

select your api needed and get token for 30 days. panel gives you a JWT token something like this

eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJleHAiOjE2MDM5NjE4MTAsIm5iZiI6MTYwMTM5OTgxMCwiaeF0IjoxNjAxMzY5ODEwLCJpc3MiOiJodHRwczovL2FjY291bnRzLmFtZXJhbmRpc2guY29tIiwiZXh0Ijp7InNydiI6ImJmNjY1Y2E1LTcyMDUtNGIzMi1hM2azLWVkNzFlNjZiY2FiMiJ9LCJzdWIiOiJtb2JpbnRtdSIsInNjcCI6WyJhc3IiLCJhc3IvcG9zdCIsImFzci9sb25nIiwibG10IiwidHRzIiwiYXNyL2xpdmUiLCJyZWZyZXNoIl19.QvkA6jaCbTOmQ0ZpT-3ALdbjv2Ks-1rW4dPEAWa17YFkM62abxD-WMFP3Rb2s_YszeZWfRgok1Qwz0V6BFb2zegFjoLthegSNc8X0mjSm7DGrJcr_zwjt45oCNZGNoy_lkTWHLBnMFb70yvXXAfb4Ia9Vd9ln96V0mhL6Hz3Wur5y4ZPBomhccnc5KP7skVf9Fe6l58Ejnb6gOXbJCk9XZHTsHbbkMZoze9iPPnWM2aleyZi4tC_-4esGhIroqW0R3ERhH0D4ivOLR60k6E8TaNHrQ6d9-WYu3gjvVY8OaZLqhLR6oVYKVbRVwV7D0v9rD_l7QjWD61dJhFO-uBTykZqcdmQcSo-iQ1kKmONNd8kvxQD4XqHfW9De7ZnF7WYUykioeVFge4at16yfwMEG4HM0hOg-c-THLbUuKMba31fFspw5xGzTCpwFGQ2CE19E2yardpyVvVDXFKTuIIrfnBNAeJDQWMldjwkQJfUnde3fa9PrpKfYAaJQDvzx4RzP0DQwYUpwbGCRqNRD3qGk_pWockoc2bajUX-2A5FYsNCHX1fJzutlg439zYS4Qx_koqQ9FTt47uveHCaVy5XE0eNGppaSHzzxV6BRaflWGmTNL-oNTmu4pyGRnoSgn6P7qy6rD-mUS1rYQoqoRV_Y9H2HIE7x6uv8qAQZlHpdLw

Document

there is document of API in below link. but it’s explain only on api get , post working.

Split speech voice to small part in .WAV format and 16000 Bit Rate

Farsava API only working on 15 sec on wav file that have 16000 bitRate. so before using API must to split it to small part.

It’s offer that using such as this operation on command line behind the customer.

installing ffmpeg to convert command and split it to small part.

ffmpeg -i inputfile.mp3 -vn -dn -ar 16000 -ac 1 -ss 0 -t 15 output.wav 2>&1

ffmpeg -i inputfile.wav -c copy -map 0 -segment_time 15 -f segment output%03d.wav

Using ASR API Restfull

for using API Farsava visit github code.

one of the annoying thing in this api is not giving complete error explain so i’m extemly emphasize to using Github Amerandish code.

for connection to the API using below command. it’s neccery to set JWT authentication to connect API.

if your code have any bug it’s only send back you false error and it’s so difficult to understand the issuse. recommending using template code at first .

Not working on Share host

if you want run this command on share host probebly you can’t convert and split sound easy beacuse offten share host did’nt have permmition to run command in background.

Sending Request One by One

another problem is you can’t send lot of request in same time and need queue processing. ASR need very resource to process these operation.