🗣️TTS Generations
Ever wanted a hot girl to say your name? Here you go.
import requests
# Define the URL for the Shard AI API endpoint.
api_url = "https://api.shard-ai.xyz/v1/audio/speech"
# Define the data to be sent in the request.
request_data = {
"model": "gtts",
"input": "kitty"
}
# Provide the authorization token for accessing the API.
authorization_token = "Bearer shard-xxx"
# Define request headers.
headers = {
"Content-Type": "application/json",
"Authorization": authorization_token
}
# Make the request.
response = requests.post(api_url, json=request_data, headers=headers)
# Check if the request was successful.
if response.ok:
# Write the response to a file.
with open("output.mp3", "wb") as f:
f.write(response.content)
print("File written successfully: output.mp3")
else:
print("Error:", response.status_code)
package main
import (
"log"
"os"
"github.com/valyala/fasthttp"
)
func main() {
// Define the URL for the Shard AI API endpoint.
apiURL := "https://api.shard-ai.xyz/v1/audio/speech"
// Define the data to be sent in the request.
requestData := `{
"model": "gtts",
"input": "kitty"
}`
// Provide the authorization token for accessing the API.
authorizationToken := "Bearer shard-xxx"
// Prepare the request.
req := fasthttp.AcquireRequest()
defer fasthttp.ReleaseRequest(req) // Don't forget to release
req.Header.SetContentType("application/json")
req.Header.SetMethod("POST")
req.Header.Set("Authorization", authorizationToken)
req.SetRequestURI(apiURL)
req.SetBodyString(requestData)
// Prepare the response.
resp := fasthttp.AcquireResponse()
defer fasthttp.ReleaseResponse(resp) // Don't forget to release
// Send the request.
if err := fasthttp.Do(req, resp); err != nil {
log.Fatalf("Error while making request: %s", err)
}
// Write the response to a file.
err := os.WriteFile("output.mp3", resp.Body(), 0644)
if err != nil {
log.Fatalf("Error while writing response to file: %s", err)
}
}
const https = require('https');
const fs = require('fs');
const apiURL = "https://api.shard-ai.xyz/v1/audio/speech";
const requestData = JSON.stringify({ model: "gtts", input: "kitty" });
const authorizationToken = "Bearer shard-xxx";
const options = {
hostname: 'api.shard-ai.xyz',
path: '/v1/audio/speech',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': authorizationToken
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => { data += chunk; });
res.on('end', () => {
fs.writeFileSync('output.mp3', data, 'binary');
console.log('File written successfully: output.mp3');
});
});
req.write(requestData);
req.end();
Returns binary data.
This error means you have exceeded your rate limit! For basic users, your rate limit is a global limit of 15 requests a minute. Upgrade to premium to get more.
{
"error": {
"message": "Something went wrong, try again later.",
"type": "error",
"param": None,
"code": None
}
}
// Sorry, something went wrong, you can try contacting us @ discord.gg/ligma!
Last updated