API / Website Integration

How to Automate Text-to-Speech in your website or application

It's easy to automate and/or integrate text to speech on your website or application. If your site uses WordPress, install our WordPress Plugin. If your site is programmed in a web application language like PHP or C#, it's easy to interface with HearWho. Simply grab your API Key (You'll need a free user account, and it's under "API" on the navigation bar). Then use or adapt the sample code below.

C# Sample Code
PHP Sample Code

C# .NET Sample Code

The following is some sample code to show you how easy it is to integrate HearWho text-to-speech services directly in your application.

Please limit calls to the API to at most 10 calls a minute.


public static async Task MakeMp3Async(string body)
{

    try
    {
        var values = new Dictionary
        {
            { "UserToken", "{YOUR_API_KEY}" },
            { "voice", "1" },
            { "speed", "1" },
            { "quality", "2" },
            { "Content", body },
        };


        var endpoint = "https://hearwho.com/api/make/";
        var content = new FormUrlEncodedContent(values);
        var response = client.PostAsync(endpoint, content).Result; 
        var responseString = await response.Content.ReadAsStringAsync();
        var MP3url = responseString.Replace("\"", "");

        return MP3url; //this will return the URL of your final MP3 file.

    }
    catch (Exception e)
    {
        //Handle exceptions here
        return "";

    }
           
}
   
                        

PHP Sample Code

The following is some sample code to show you how easy it is to integrate HearWho text-to-speech services directly in your application.

Please limit calls to the API to at most 10 calls a minute.


 function send_to_hearwho ($content, $apiKey ) {


	$url = "https://hearwho.com/api/make/";

	$data = array(  'UserToken' => $apiKey,
					'voice' => '1',
					  'speed' => '1',
					  'quality' => '2',
					   'Content'   => $content

					);

	$options = array(
		'http' => array(
			'header'  => 'Content-type: application/x-www-form-urlencoded',
			'method'  => 'POST',
			'content' => http_build_query($data)
		)
	);
	


	$context  = stream_context_create($options);
	$resp = file_get_contents($url, false, $context);	 

	return str_replace('"','',$resp);
}