MyCaption API is a small and simple API based on HTTP. At the heart of it are just two transactions -- you post an audio file, you get back a text file. The turnaround time is in seconds to minutes, depending on the duration of your audio recording. You have to specify a callback URL along with your audio upload, and the system posts the transcription back to that URL. You don't have to fetch it.

MyCaption offers three classes of speech-to-text API products: Speech Recognition, Premium Dictation, and Dynamic Form. Currently, only Speech Recognition is available on Mashape. For other products, please contact MyCaption.

Speech Recognition provides fast, inexpensive conversion of speech to text. It uses machine-based (automatic) speech recognition technology. Accuracy depends on background noise, speaker accent, and clarity of enunciation. Best suited for inexpensive message transcription and data mining. Your message must be English language speech, single speaker, with audio duration up to 3 minutes. Audio format can be wav or mp3.

Questions? Send us an email: api@mycaption.com.

Before You Code

Please test and debug your Callback URL first, before making calls to MyCaption API. For debugging the Callback functionality, we recommend you use a good tool like Google Chrome browser's Postman plugin. Using this tool, before consuming MyCaption API, please make sure that an http POST call to your Callback URL is working correctly.

Please use the following sample code instead of the Unirest library -- the test console of Mashape currently does not support including a binary file as part of POST body.. While coding, if you run into a problem, send an email to api@mycaption.com -- very likely, we will respond quickly, often even on weekends. In any case, please do NOT flood the API with repeated calls if something doesn't work -- it won't help, and will only further delay your API response.

No matter what programming language you use, there is usually a way to include a Curl command by calling Shell. You may find that to be the fastest way to get going.

Sample Code, Curl Command:

The audio file is to be uploaded in the body of the HTTP POST. Here is how you would do it using Curl. In this example, your wav audio file is 8 seconds long.

curl -k -v -H "Expect: " -H "Content-Type:application/octet-stream"  -H "X-Mashape-Authorization: <your_token_here>"   --data-binary '@test.wav' -X POST 'https://mycaption-speech.p.mashape.com/asr?audio_duration=8&reference=abcxyz&audio_format=wav&callback=http://<your_callback_server_URL_here>'

The binary contents of the file test.wav will be sent in the body of the HTTP POST.

Sample Code in PHP:

(Contributed by Vladimir Polyakov <vovan_983@ mail.ru> , Revised by Victor Bailey. Thanks to both.)

How to upload audio:


<?php
$audio_duration = 30; // put correct audio_duration here
$audio_format = 'wav';
$filename = 'test.wav';
$file = '/path/to/audio_file/test.wav';
$callback = urlencode('http://YOUR/DOMAIN/exampleCallback.php');
$post_url = "https://mycaption-speech.p.mashape.com/asr?audio_duration=$audio_duration&callback=$callback&audio_format=$audio_format";
$post_str = file_get_contents($file);
$headers = array('Content-Type:application/octet-stream', 'Expect: ', 'X-Mashape-Authorization: <your_token_here>');
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_VERBOSE,true); 
//curl_setopt($ch, CURLOPT_STDERR, fopen("/path/to/your/headers.txt", "w+"));//if you want log headers.
$http_body = curl_exec($ch);
if ($http_body === false)
$http_body = array('Curl error: '. curl_error($ch));
echo htmlentities(print_r($http_body, true), null, 'UTF-8');
?>

Once the transcription is ready, it will POSTed back to your callback URL you specified when uploading the audio. Here is an example of how you can parse the incoming response:

<?php
$text = date('Y-m-d h:i:s')." :\n";
if (isset($_POST['message_id']) && isset($_POST['transcription']))
{
//put $_POST['message_id'], $_POST['transcription'] to your database or

   foreach($_POST as $key => $value)
{
$text = $text . "$key => $value \n"; 
}
$file = fopen('post.txt', "a+");
fwrite($file, $text);
fclose($file);
exit();
}
?>

Sample Code in Ruby


# Client class to consume MyCaption speech-to-text API
# In this example, we upload audio for Speech Recognition (path /asr)

require 'httparty'
require 'base64'
require 'builder'
require 'rexml/document'

class Myapi

  include HTTParty  
  base_uri 'https://mycaption-speech.p.mashape.com'

 def initialize(audio, audio_duration, reference, callback, audio_format, mashape_token)
   @audio = audio
   @audio_duration = audio_duration
   @reference = reference
   @callback = callback
   @audio_format = audio_format
   @mashape_token = mashape_token
end

  # Upload voice file to MyCaption API.
  # After executing this call,
  # wait a while and issue download_text_data call.
  def upload_voice
    begin
      @path = '/asr'
      build_headers
      build_query_parameters
      build_body
      @options = {:query => @query_parameters, :headers => @headers, :body => @body}
      http_response = self.class.post(@path, @options)    
      http_response.body
    rescue Exception => e
      puts e.message
    end
  end


  private


  def build_headers
    @headers = Hash.new
    @headers['content-type'] = 'application/octet-stream'
    @headers['X-Mashape-Authorization'] = @mashape_token    
  end

  def build_query_parameters
    @query_parameters = Hash.new
    @query_parameters[:audio_duration] = @audio_duration
    @query_parameters[:reference] = @reference
    @query_parameters[:callback] = @callback
    @query_parameters[:audio_format] = @audio_format    
  end


  def build_body
     @body = @audio  
  end

end # class

Run the script


audio = open("test.wav", "rb")   { |f| f.read }
audio_duration = '8' # seconds. Replace with correct value.
reference = 'abcxyz' # your reference, can be any string
callback =  'http://myserver.com/incoming/transcription'  
audio_format = 'wav' 
mashape_token = abcdefghijklmnopq # your Mashape token here
myapi = Myapi.new(audio, audio_duration, reference, callback, audio_format, mashape_token)
result = myapi.upload_voice
puts result

Keywords

Speech to text, voice to text, voice recognition, transcription, audio conversion to text, convert audio to text.

Please read

http://mycaption.com/terms

Also:

Minutes are counted in 15-seconds increments. For example, if your message is 22 seconds long, it is counted as half a minute.

Last 7 days, UTC

Average Latency
2ms

Average Uptime
100.0%

Current Status
Online

  • No information
  • Outage
  • Disruption
  • Normal
Average latency determined from Mashape to API Response time

Simple & Straightforward Pricing

Pay as you go. No long-term contracts.

Freemium

$0

additional fees may apply

audio_minutes

30 / mo.

$0.1200 per extra

Limited to 30 days and new users only This rule applies to Freemium plan only.

Subscribe

basic

$20.00

per month

audio_minutes

200 / mo.

$0.1100 per extra

Subscribe

ultra

$100.00

per month

audio_minutes

1,300 / mo.

$0.0900 per extra

Subscribe

Asr

HTTP 200 : string POST/asr
asr

Upload audio to be processed by automatic speech recognition engine.


Test console
Description
Parameter
string

Duration of audio file, in seconds. 1 to 180.
Example: 22

audio_duration

Required

string

Any string that you can use to track this file. When you receive your transcription back, this reference will be included for your information.
Example: myfile-12345

reference

Optional

string

A URL at which your transcription will be HTTP POST-ed when ready. This eliminates the chore of fetching transcribed files yourself. You will need to implement a web server that is able to receive this callback.
Example: http://myserver.com/incoming/transcription

callback

Required

string

wav or mp3
Example: wav

audio_format

Required

string

The format in which you want the response returned. Choices: json or xml. Default: json.
Example: xml

format

Optional

binary

See README. Don't try test console.
Example: NOTE: body contains binary audio

(no_parameter)

Required

You must have an API key to test this API!


Mashape allows developers to find, consume, and distribute cloud APIs just like Speech Recognition.

Login to your account or signup: Create Account

or
   Signup with GitHub

By signing up you agree to our terms of service.