imseldrith commited on
Commit
8ec60ec
·
verified ·
1 Parent(s): 77072a1

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +177 -0
index.html ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
+ <title>Text-to-Speech API Documentation</title>
8
+ <style>
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ background-color: #f4f4f4;
12
+ color: #333;
13
+ margin: 0;
14
+ padding: 0;
15
+ }
16
+ header {
17
+ background-color: #4CAF50;
18
+ color: white;
19
+ padding: 20px;
20
+ text-align: center;
21
+ }
22
+ h1, h2 {
23
+ margin: 0;
24
+ }
25
+ section {
26
+ margin: 20px;
27
+ padding: 20px;
28
+ background-color: white;
29
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
30
+ }
31
+ pre {
32
+ background-color: #f4f4f4;
33
+ padding: 10px;
34
+ border-radius: 5px;
35
+ font-family: monospace;
36
+ overflow-x: auto;
37
+ }
38
+ footer {
39
+ text-align: center;
40
+ padding: 10px 0;
41
+ background-color: #4CAF50;
42
+ color: white;
43
+ }
44
+ ul {
45
+ line-height: 1.6;
46
+ }
47
+ </style>
48
+ </head>
49
+ <body>
50
+
51
+ <header>
52
+ <h1>Text-to-Speech (TTS) API Documentation</h1>
53
+ <p>Convert text into high-quality speech using our API</p>
54
+ </header>
55
+
56
+ <section>
57
+ <h2>API Overview</h2>
58
+ <p>This API allows you to convert text into natural-sounding speech. You can specify the voice and model for the TTS generation. It is ideal for use cases such as games, tutorials, and accessibility applications.</p>
59
+ </section>
60
+
61
+ <section>
62
+ <h2>API Endpoint</h2>
63
+ <p>To generate speech, send a POST request to the following URL:</p>
64
+ <pre>https://imseldrith-tts-openai-free.hf.space/v1/audio/speech</pre>
65
+ </section>
66
+
67
+ <section>
68
+ <h2>Request Example</h2>
69
+ <p>Here’s an example of the JSON payload you’ll need to send in your POST request:</p>
70
+ <pre>
71
+ {
72
+ "model": "tts-1",
73
+ "input": "Today is a wonderful day to build something people love!",
74
+ "voice": "echo"
75
+ }
76
+ </pre>
77
+ </section>
78
+
79
+ <section>
80
+ <h2>Voice Options</h2>
81
+ <p>Choose from the following voices for speech synthesis:</p>
82
+ <ul>
83
+ <li><strong>alloy</strong>: A deep and rich voice.</li>
84
+ <li><strong>echo</strong>: A soft, echoing voice.</li>
85
+ <li><strong>fable</strong>: A calm, neutral voice.</li>
86
+ <li><strong>onyx</strong>: A slightly robotic, futuristic voice.</li>
87
+ <li><strong>nova</strong>: A bright and clear voice.</li>
88
+ <li><strong>shimmer</strong>: A soft, dreamy voice.</li>
89
+ </ul>
90
+ </section>
91
+
92
+ <section>
93
+ <h2>Audio Quality Options</h2>
94
+ <p>You can choose between two models based on the quality of the audio and latency requirements:</p>
95
+ <ul>
96
+ <li><strong>tts-1</strong>: The standard model that provides low latency but may have some static or lower quality in certain situations. Ideal for real-time applications.</li>
97
+ <li><strong>tts-1-hd</strong>: A high-definition model that produces better quality audio at the cost of higher latency. Recommended for non-realtime applications where quality is a priority.</li>
98
+ </ul>
99
+ </section>
100
+
101
+ <section>
102
+ <h2>How to Use the API</h2>
103
+ <p>Use the following code examples to make requests to the API. You can copy and modify the code as needed.</p>
104
+
105
+ <h3>Python Code Example</h3>
106
+ <p>This Python example demonstrates how to send a POST request to the API and save the generated speech as an MP3 file:</p>
107
+ <pre>
108
+ import requests
109
+
110
+ # API URL and Headers
111
+ url = "https://imseldrith-tts-openai-free.hf.space/v1/audio/speech"
112
+ headers = {
113
+ "Content-Type": "application/json"
114
+ }
115
+
116
+ # Payload with input text and desired voice
117
+ data = {
118
+ "model": "tts-1", # Use "tts-1-hd" for higher quality audio
119
+ "input": "Today is a wonderful day to build something people love!",
120
+ "voice": "echo" # Choose a voice (e.g., "alloy", "echo", "fable", etc.)
121
+ }
122
+
123
+ # Make the POST request
124
+ response = requests.post(url, headers=headers, json=data)
125
+
126
+ # Save the response content to an MP3 file if the request is successful
127
+ if response.status_code == 200:
128
+ with open("speech.mp3", "wb") as f:
129
+ f.write(response.content)
130
+ print("Speech file saved as 'speech.mp3'")
131
+ else:
132
+ print(f"Failed to generate speech: {response.status_code}, {response.text}")
133
+ </pre>
134
+
135
+ <h3>cURL Command Example</h3>
136
+ <p>If you prefer using cURL, you can make the request like this:</p>
137
+ <pre>
138
+ curl -X POST https://imseldrith-tts-openai-free.hf.space/v1/audio/speech \
139
+ -H "Content-Type: application/json" \
140
+ -d '{
141
+ "model": "tts-1",
142
+ "input": "Today is a wonderful day to build something people love!",
143
+ "voice": "echo"
144
+ }' --output speech.mp3
145
+ </pre>
146
+
147
+ <h3>JavaScript (Fetch) Example</h3>
148
+ <p>Here’s how you can make a POST request to the TTS API using JavaScript (for example, in a web application):</p>
149
+ <pre>
150
+ fetch("https://imseldrith-tts-openai-free.hf.space/v1/audio/speech", {
151
+ method: "POST",
152
+ headers: {
153
+ "Content-Type": "application/json"
154
+ },
155
+ body: JSON.stringify({
156
+ model: "tts-1", // Use "tts-1-hd" for higher quality audio
157
+ input: "Today is a wonderful day to build something people love!",
158
+ voice: "echo" // Choose a voice (e.g., "alloy", "echo", "fable", etc.)
159
+ })
160
+ })
161
+ .then(response => response.blob())
162
+ .then(blob => {
163
+ const link = document.createElement("a");
164
+ link.href = URL.createObjectURL(blob);
165
+ link.download = "speech.mp3";
166
+ link.click();
167
+ })
168
+ .catch(error => console.error("Error:", error));
169
+ </pre>
170
+ </section>
171
+
172
+ <footer>
173
+ <p></p>
174
+ </footer>
175
+
176
+ </body>
177
+ </html>