API response time too high -- Please help #164
-
Hi there, https://developers.deepgram.com/reference/pre-recorded I am using Prerecorded audio file and my file size is 200 MB and its 18 minutes and getting response in 8-10 minutes using the API. Coding language is PHP and used the same code as show in https://developers.deepgram.com/reference/pre-recorded How i can reduce the response time, please help. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
Hey @pdns90, can you provide a little more info about the file you're sending over? What is the file type? Did you try a smaller file? Can you share the code, including any features/options you've included? |
Beta Was this translation helpful? Give feedback.
-
@pdns90 are you able to share the file? If not, give me a little time to find a suitable alternative. |
Beta Was this translation helpful? Give feedback.
-
@pdns90 so, I've tried a 26mb mp3 of a speech from Wikipedia. I made the request from my terminal, so not exactly the same. But here is my request... Please use this file from your server, and let me know if it's as slow for you. If it is as slow from your CDN, it may be a bandwidth limit problem with where you are hosting your file. Here you'll see I uploaded this to our cloudinary CDN quickly. In this case, I would suggest reading the file from your server as a local file (if possible), or finding a host for your file without limited bandwidth. Some untested PHP that reads a file from disk: <?php
require_once 'vendor/autoload.php';
$client = new \GuzzleHttp\Client();
$audio = fopen('/path/to/audio.mp3', 'r');
$response = $client->request('POST', 'https://api.deepgram.com/v1/listen', [
'body' => $audio,
'headers' => [
'Authorization' => 'Token xxxxxx',
'accept' => 'application/json',
'content-type' => 'audio/mpeg',
],
]);
echo $response->getBody(); If it is not as slow from your CDN, I would prefer to test it with your file to see if it is a problem with that file, or how we are receiving that file. My tests: curl -w "@curl-format.txt" --request POST \
--url https://api.deepgram.com/v1/listen \
--header 'Authorization: Token xxxxxx' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"url": "https://res.cloudinary.com/deepgram/video/upload/v1685106433/dg-audio/stanford_rjb4xa.mp3"
}
' The file time_namelookup: %{time_namelookup}s\n
time_connect: %{time_connect}s\n
time_appconnect: %{time_appconnect}s\n
time_pretransfer: %{time_pretransfer}s\n
time_redirect: %{time_redirect}s\n
time_starttransfer: %{time_starttransfer}s\n
----------\n
time_total: %{time_total}s\n The resulting request:
|
Beta Was this translation helpful? Give feedback.
-
It would be interesting to see how it handled the file being read from a filepath, rather than a URL. I believe what we might be seeing is the result of one or more HTTP requests being restricted by available bandwidth. You can email your file to [email protected] and I'll try it from my end. Thanks for sticking with it! |
Beta Was this translation helpful? Give feedback.
-
Hey @pdns90 I tried your file from my local machine. 212.1mb transcribed in 1 minute. My request: curl -w "@curl-format.txt" --request POST \
--url https://api.deepgram.com/v1/listen \
--header 'Authorization: Token xxxxx' \
--header 'accept: application/json' \
--header 'content-type: audio/mp3' \
--data-binary @/Users/lukeoliff/Downloads/xxx.mp3 This is the result: time_namelookup: 0.001613s
time_connect: 0.126888s
time_appconnect: 0.389840s
time_pretransfer: 0.389899s
time_redirect: 0.000000s
time_starttransfer: 0.557873s
----------
time_total: 57.727225s Going back to my original thought, I think it may be to do with where you are hosting that file. If you're using the server that I downloaded the file from, I am on a gigabit connection and I usually get around 500/mb down, but for your file download I got 200kb download. If you want to run your file locally, you can use this code on your own machine: <?php
require_once 'vendor/autoload.php';
$client = new \GuzzleHttp\Client();
$audio = fopen('/the/file/on/your/machine/xxx.mp3', 'r'); // make this the FILE PATH, not a URL
$response = $client->request('POST', 'https://api.deepgram.com/v1/listen', [
'body' => $audio,
'headers' => [
'Authorization' => 'Token xxxxxx',
'accept' => 'application/json',
'content-type' => 'audio/mpeg',
],
]);
echo $response->getBody(); Important notes about making the most of slower connections:
ConclusionRunning your 200mb file for me took 1 minute. I think Deepgram is taking a long time to get the file, but only because the server where the file is located is limited or having a problem with bandwidth. A screenshot of the download of the .zip file |
Beta Was this translation helpful? Give feedback.
No for a 200mb file I think that is an acceptable amount of time, especially from a local machine. I think the server you've used has a bandwidth limitation. You should consider using a CDN like cloudflare to host your file.