-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.php
More file actions
80 lines (67 loc) · 2.23 KB
/
Copy pathweb.php
File metadata and controls
80 lines (67 loc) · 2.23 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* VFN-TTS demo
* Developer: OmarRizk
* Developed since 2019.
* generate audio.
*/
@ini_set('display_errors','0');
error_reporting(E_ALL);
require __DIR__.'/VFN_TTS/VFN_TTS.php';
$text=isset($_POST['text'])?trim((string)$_POST['text']):'';
$language=isset($_POST['language'])?trim((string)$_POST['language']):'auto';
$error='';
$audioUrl='';
if($_SERVER['REQUEST_METHOD']==='POST' && $text!==''){
try{
$outDir=__DIR__.'/generated';
if(!is_dir($outDir)&&!@mkdir($outDir,0775,true)&&!is_dir($outDir)){
throw new Exception('Cannot create generated directory.');
}
$name='speech_'.date('Ymd_His').'_'.substr(sha1(uniqid('',true)),0,8).'.wav';
$output=$outDir.'/'.$name;
$tts=new FvnTTS(__DIR__.'/VFN_TTS/voices');
$tts->voice('orizk');
$tts->save($text,$output,array(
'language'=>$language,
'emoji_mode'=>'expressive'
));
$audioUrl='generated/'.$name;
}catch(Exception $e){
$error='تعذر توليد الصوت لهذا النص.';
}
}
function vfn_h($x){
return htmlspecialchars((string)$x,ENT_QUOTES,'UTF-8');
}
?>
<!doctype html>
<html lang="ar" dir="rtl">
<head>
<meta charset="utf-8">
<title>VFN-TTS</title>
</head>
<body>
<h1>VFN-TTS</h1>
<p>Developer: OmarRizk — Developed since 2019</p>
<form method="post">
<textarea name="text" rows="8" cols="70" required><?php echo vfn_h($text); ?>🤧 انا مبرمج اللي طورت النموذج</textarea>
<br>
<select name="language">
<option value="auto"<?php echo $language==='auto'?' selected':''; ?>>Auto</option>
<option value="ar"<?php echo $language==='ar'?' selected':''; ?>>Arabic</option>
<option value="en"<?php echo $language==='en'?' selected':''; ?>>English</option>
<option value="fr"<?php echo $language==='fr'?' selected':''; ?>>French</option>
</select>
<button type="submit">توليد الصوت</button>
</form>
<?php if($error!==''): ?>
<p><?php echo vfn_h($error); ?></p>
<?php endif; ?>
<?php if($audioUrl!==''): ?>
<p>تم التوليد:</p>
<audio controls autoplay src="<?php echo vfn_h($audioUrl); ?>"></audio>
<p><a href="<?php echo vfn_h($audioUrl); ?>" download>تحميل المقطع</a></p>
<?php endif; ?>
</body>
</html>