area444 commited on
Commit
0cac409
·
verified ·
1 Parent(s): 3a893e9

Upload API_DOC.md

Browse files
Files changed (1) hide show
  1. API_DOC.md +208 -0
API_DOC.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # **API Documentation**
2
+
3
+ This is the API documentation for the FastAPI application. The following endpoints are available:
4
+
5
+ ---
6
+
7
+ ### `POST /synthesize/`
8
+
9
+ **Summary**: Synthesize
10
+
11
+ - **Description**: This endpoint is used to generate synthesized output based on the provided text.
12
+
13
+ - **Parameters**:
14
+ - **`text`** (query) **Required**: The text you want to synthesize (string).
15
+ - **`return_base64`** (query) **Optional**: Whether to return the result in base64 format. Default is `true` (boolean).
16
+ - **`diffusion_steps`** (query) **Optional**: Number of diffusion steps to perform. Minimum is 5, maximum is 200. Default is 5 (integer).
17
+ - **`embedding_scale`** (query) **Optional**: Scaling factor for embedding. Minimum is 1.0, maximum is 5.0. Default is 1.0 (number).
18
+
19
+ - **Responses**:
20
+ - **Curl** (example):
21
+ ```curl
22
+ curl -X 'POST' \
23
+ 'http://127.0.0.1:8000/synthesize/?text=StyleTTS%202%20is%20a%20text%20to%20speech%20model%20that%20leverages%20style%20diffusion%20and%20adversarial%20training%20with%20large%20speech%20language%20models%20to%20achieve%20human%20level%20text%20to%20speech%20synthesis.&return_base64=true&diffusion_steps=5&embedding_scale=1' \
24
+ -H 'accept: application/json' \
25
+ -d ''
26
+ ```
27
+ - **200 OK**: Successful Response
28
+ - Example Response (JSON):
29
+ ```json
30
+ {}
31
+ ```
32
+ - **422 Unprocessable Entity**: Validation Error
33
+ - Example Response (JSON):
34
+ ```json
35
+ {
36
+ "detail": [
37
+ {
38
+ "loc": ["query", "text"],
39
+ "msg": "field required",
40
+ "type": "value_error.missing"
41
+ }
42
+ ]
43
+ }
44
+ ```
45
+
46
+ ---
47
+
48
+ ### `POST /synthesize_longform_streaming/`
49
+
50
+ **Summary**: Synthesize Longform
51
+
52
+ - **Description**: This endpoint generates longform synthesized content based on the provided passage.
53
+
54
+ - **Parameters**:
55
+ - **`passage`** (query) **Required**: The passage text to synthesize (string).
56
+ - **`return_base64`** (query) **Optional**: Whether to return the result in base64 format. Default is `false` (boolean).
57
+ - **`alpha`** (query) **Optional**: A scaling factor for the synthesis (number). Default is 0.7, minimum is 0.0, maximum is 1.0.
58
+ - **`diffusion_steps`** (query) **Optional**: Number of diffusion steps to perform. Minimum is 5, maximum is 200. Default is 10 (integer).
59
+ - **`embedding_scale`** (query) **Optional**: Scaling factor for embedding. Minimum is 1.0, maximum is 5.0. Default is 1.5 (number).
60
+
61
+ - **Responses**:
62
+ - **Curl** (example):
63
+ ```curl
64
+ curl -X 'POST' \
65
+ 'http://127.0.0.1:8000/synthesize_longform_streaming/?passage=%27%27%27If%20the%20supply%20of%20fruit%20is%20greater%20than%20the%20family%20needs%2C%20it%20may%20be%20made%20a%20source%20of%20income%20by%20sending%20the%20fresh%20fruit%20to%20the%20market%20if%20there%20is%20one%20near%20enough%2C%20or%20by%20preserving%2C%20canning%2C%20and%20making%20jelly%20for%20sale.%20To%20make%20such%20an%20enterprise%20a%20success%20the%20fruit%20and%20work%20must%20be%20first%20class.%20There%20is%20magic%20in%20the%20word%20%22Homemade%2C%22%20when%20the%20product%20appeals%20to%20the%20eye%20and%20the%20palate%3B%20but%20many%20careless%20and%20incompetent%20people%20have%20found%20to%20their%20sorrow%20that%20this%20word%20has%20not%20magic%20enough%20to%20float%20inferior%20goods%20on%20the%20market.%20As%20a%20rule%20large%20canning%20and%20preserving%20establishments%20are%20clean%20and%20have%20the%20best%20appliances%2C%20and%20they%20employ%20chemists%20and%20skilled%20labor.%20The%20home%20product%20must%20be%20very%20good%20to%20compete%20with%20the%20attractive%20goods%20that%20are%20sent%20out%20from%20such%20establishments.%20Yet%20for%20first-class%20homemade%20products%20there%20is%20a%20market%20in%20all%20large%20cities.%20All%20first-class%20grocers%20have%20customers%20who%20purchase%20such%20goods.%27%27%27&return_base64=false&alpha=0.7&diffusion_steps=10&embedding_scale=1.5' \
66
+ -H 'accept: application/json' \
67
+ -d ''
68
+ ```
69
+ - **200 OK**: Successful Response
70
+ - Example Response (JSON):
71
+ ```json
72
+ {}
73
+ ```
74
+ - **422 Unprocessable Entity**: Validation Error
75
+ - Example Response (JSON):
76
+ ```json
77
+ {
78
+ "detail": [
79
+ {
80
+ "loc": ["query", "passage"],
81
+ "msg": "field required",
82
+ "type": "value_error.missing"
83
+ }
84
+ ]
85
+ }
86
+ ```
87
+
88
+ ---
89
+
90
+ ### `POST /synthesize_with_emotion/`
91
+
92
+ **Summary**: Synthesize With Emotion
93
+
94
+ - **Description**: This endpoint allows the synthesis of content with emotional tone.
95
+
96
+ - **Parameters**:
97
+ - **`return_base64`** (query) **Optional**: Whether to return the result in base64 format. Default is `true` (boolean).
98
+ - **`diffusion_steps`** (query) **Optional**: Number of diffusion steps to perform. Minimum is 5, maximum is 200. Default is 100 (integer).
99
+ - **`embedding_scale`** (query) **Optional**: Scaling factor for embedding. Minimum is 1.0, maximum is 5.0. Default is 5.0 (number).
100
+
101
+ - **Request Body**:
102
+ - **Required**: A JSON object containing the texts to be synthesized.
103
+ - Example Request Body:
104
+ ```json
105
+ {
106
+ "texts": ["Text 1", "Text 2"]
107
+ }
108
+ ```
109
+
110
+ - **Responses**:
111
+ - **200 OK**: Successful Response
112
+ - Example Response (JSON):
113
+ ```json
114
+ {}
115
+ ```
116
+ - **422 Unprocessable Entity**: Validation Error
117
+ - Example Response (JSON):
118
+ ```json
119
+ {
120
+ "detail": [
121
+ {
122
+ "loc": ["query", "return_base64"],
123
+ "msg": "value is not a boolean",
124
+ "type": "type_error.bool"
125
+ }
126
+ ]
127
+ }
128
+ ```
129
+
130
+ ---
131
+
132
+ ### `POST /synthesize_streaming_audio/`
133
+
134
+ **Summary**: Synthesize Streaming Audio
135
+
136
+ - **Description**: This endpoint generates streaming audio based on the provided text.
137
+
138
+ - **Parameters**:
139
+ - **`text`** (query) **Required**: The text to synthesize into audio (string).
140
+ - **`return_base64`** (query) **Optional**: Whether to return the result in base64 format. Default is `false` (boolean).
141
+ - **`diffusion_steps`** (query) **Optional**: Number of diffusion steps to perform. Minimum is 5, maximum is 200. Default is 5 (integer).
142
+ - **`embedding_scale`** (query) **Optional**: Scaling factor for embedding. Minimum is 1.0, maximum is 5.0. Default is 1.0 (number).
143
+
144
+ - **Responses**:
145
+ - **Curl** (example):
146
+ ```curl
147
+ curl -X 'POST' \
148
+ 'http://127.0.0.1:8000/synthesize_with_emotion/?return_base64=true&diffusion_steps=100&embedding_scale=5' \
149
+ -H 'accept: application/json' \
150
+ -H 'Content-Type: application/json' \
151
+ -d '{"Happy": "We are happy to invite you to join us on a journey to the past, where we will visit the most amazing monuments ever built by human hands.",
152
+ "Sad": "I am sorry to say that we have suffered a severe setback in our efforts to restore prosperity and confidence.",
153
+ "Angry": "The field of astronomy is a joke! Its theories are based on flawed observations and biased interpretations!",
154
+ "Surprised": "I can'\''t believe it! You mean to tell me that you have discovered a new species of bacteria in this pond?"}'
155
+ ```
156
+ - **200 OK**: Successful Response
157
+ - Example Response (JSON):
158
+ ```json
159
+ {}
160
+ ```
161
+ - **422 Unprocessable Entity**: Validation Error
162
+ - Example Response (JSON):
163
+ ```json
164
+ {
165
+ "detail": [
166
+ {
167
+ "loc": ["query", "text"],
168
+ "msg": "field required",
169
+ "type": "value_error.missing"
170
+ }
171
+ ]
172
+ }
173
+ ```
174
+
175
+ ---
176
+
177
+ ## **Components**
178
+
179
+ ### **Schemas**
180
+
181
+ #### `HTTPValidationError`
182
+
183
+ - **Description**: Schema for validation errors in the API.
184
+ - **Properties**:
185
+ - **`detail`**: List of validation errors (array of `ValidationError` objects).
186
+
187
+ #### `ValidationError`
188
+
189
+ - **Description**: Represents a single validation error.
190
+ - **Properties**:
191
+ - **`loc`**: Location of the error (array of strings or integers).
192
+ - **`msg`**: Error message (string).
193
+ - **`type`**: Type of error (string).
194
+
195
+ ---
196
+
197
+ ### **Conclusion**
198
+
199
+ This documentation provides a summary of the available API endpoints, parameters, responses, and error handling for the FastAPI application. Make sure to follow the guidelines for providing the correct parameters and formats when interacting with these endpoints.
200
+
201
+ ---
202
+
203
+ ### Notes:
204
+
205
+ - **Default Values**: Default values for optional query parameters are listed in the descriptions.
206
+ - **Error Handling**: All endpoints return a `422 Unprocessable Entity` error for validation failures with a detailed message.
207
+
208
+ ---