-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlooma-speech.php
More file actions
27 lines (21 loc) · 1013 Bytes
/
looma-speech.php
File metadata and controls
27 lines (21 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
/*
Author: Akshay Srivatsan
Date: August 7, 2015
Notes: if this file causes an empty response, make sure the directory "tmp" exists.
In addition, make sure PHP has permission to write into that directory (call "chmod 777 /var/www/html/Looma/tmp").
NOTE [skip] to avoid conflicts between multiple simultaneous users
i. name the tmp .wav file "tmp/" . uniqid() . ".wav"
and ii. delete the file after sending it the client
*/
//uses PICO2WAVE to generate WAV file on the server side
// not currently used - replaced by MIMIC TTS [file=looma-mimic.php]
header("Access-Control-Allow-Origin: *");
header("Content-Type: audio/wav");
//$text = urldecode($_GET["text"]); //skip's version
$text = htmlspecialchars($_GET["text"]); //akshay's version
$unique_filename = "/tmp/" . uniqid("audio") . ".wav"; //unique filename prefixed with "audio"
exec('pico2wave -w ' . $unique_filename . ' "' . $text . '"');
readfile($unique_filename);
exec('rm ' . $unique_filename);
?>