# Combine Bing Search with text to speech

**URL:** <https://forum.kirupa.com/t/combine-bing-search-with-text-to-speech/319573>\
**Category:** Uncategorized\
**Created:** [February 24, 2011, 8:27pm UTC](https://forum.kirupa.com/t/combine-bing-search-with-text-to-speech/319573 "2011-02-24T20:27:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iso\_Rob](https://avatars.discourse-cdn.com/v4/letter/i/c68b51/32.png) [@Iso\_Rob](https://forum.kirupa.com/u/Iso_Rob)\
**Post date:** [February 24, 2011, 8:27pm UTC](https://forum.kirupa.com/t/combine-bing-search-with-text-to-speech/319573/1 "2011-02-24T20:27:11Z")

</div>

Hi all,

I’ve found some code that reads out some text when submitted (I adjusted it slightly so it does it on the fly rather than going to another site), how can I combine this with Bing’s search API?

Here’s the text to speech code:

```auto
<form method="post" action="http://vozme.com/text2voice.php" target="hiddeniframe">
<textarea id="text" cols="40" rows="1" name="text">
Enter Text
</textarea><br>
<button style="background-color:white;
background-image:
url(http://vozme.com/img/megaphone40x40w.gif);
background-position: top center;
background-repeat:no-repeat;
height: 48px; font-size:70%;
padding:4px 4px 4px 44px;">
</button>
</form>
 
<iframe height="1" width="1" name="hiddeniframe" style="display: none;"></iframe>

```

Here’s the Bing API:

```php
<html>
<head>
   <link href="styles.css" rel="stylesheet" type="text/css" />
<title>PHP Bing</title>
</head>
<body>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> 
Enter Search:<input type="text" id="searchText" name="searchText" value="<?php 
if (isset($_POST['searchText'])){
  echo($_POST['searchText']); }
else { 
echo('');
} ?>"/>

<input type="submit" value="Search!" name="submit" id="searchButton" />
<?php
if (isset($_POST['submit'])) {

$request = 
'http://api.bing.net/json.aspx?Appid=8CFD0925A6B1745AFE2F0F359DCD8D4D9DD6A5CE&sources=web&Web.Count=5&query=' . urlencode( $_POST["searchText"]);$response = file_get_contents($request);
$jsonobj = json_decode($response);
echo('<ul ID="resultList">');                    

foreach($jsonobj->SearchResponse->Web->Results as $value) {

echo('<li class="resultlistitem"><a href="' . $value->Url . '">'. $value->Title .'</a>');
echo('<p>'. $value->Description .'</p>');
echo('</li>');
}
echo("</ul>");
}
?>
</form>
</body>
</html>

```

What I want to happen is when you click a submit it reads out the text in the box and shows the Bing results as normal.

Cheers
