DeFactOfficial commited on
Commit
2544d8e
1 Parent(s): ae8262b

Update api.js

Browse files
Files changed (1) hide show
  1. api.js +21 -3
api.js CHANGED
@@ -209,7 +209,7 @@ app.get('api/generate/utterance', async (req, res) => {
209
  const outputFilename= await generateAudio(voice, text, model || "tts-1")
210
 
211
  // We want the browser to cache this response, because there's no reason to TTS the same text-voice-model combination more than once
212
- res.sendFile(path.resolve(outputFilename), { headers: { 'Content-Type': 'audio/mpeg', 'Cache-Control', 'Max-Age=8640000' } });
213
  })
214
 
215
  app.post('api/generate/utterance', async (req, res) =>{
@@ -217,7 +217,7 @@ app.post('api/generate/utterance', async (req, res) =>{
217
  const outputFilename= await generateAudio(voice, text, model || "tts-1")
218
 
219
  // We want the browser to cache this response, because there's no reason to TTS the same text-voice-model combination more than once
220
- res.sendFile(path.resolve(outputFilename), { headers: { 'Content-Type': 'audio/mpeg', 'Cache-Control', 'Max-Age=8640000' } });
221
  })
222
 
223
 
@@ -292,7 +292,25 @@ app.post('/api/generate/speech/stream', async (req, res) => {
292
  }
293
  });
294
 
295
- //for prompt-in-url: <img src="https://yourserver.com/generate/image?prompt=A%20large%20hamster&width=1024&height=1024"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  app.get('/api/generate/image', async (req, res) => {
297
  const responseFormat = req.query.response_format || 'image';
298
  await generateImage(req.query, res, responseFormat)
 
209
  const outputFilename= await generateAudio(voice, text, model || "tts-1")
210
 
211
  // We want the browser to cache this response, because there's no reason to TTS the same text-voice-model combination more than once
212
+ res.sendFile(path.resolve(outputFilename), { headers: { 'Content-Type': 'audio/mpeg', 'Cache-Control':'Max-Age=8640000' } });
213
  })
214
 
215
  app.post('api/generate/utterance', async (req, res) =>{
 
217
  const outputFilename= await generateAudio(voice, text, model || "tts-1")
218
 
219
  // We want the browser to cache this response, because there's no reason to TTS the same text-voice-model combination more than once
220
+ res.sendFile(path.resolve(outputFilename), { headers: { 'Content-Type': 'audio/mpeg', 'Cache-Control':'Max-Age=8640000' } });
221
  })
222
 
223
 
 
292
  }
293
  });
294
 
295
+
296
+ //Image generation parameters
297
+ //response_format: image | url
298
+ //prompt: the text prompt for generating the image. Length is not capped, however, most models only see the first 50 words (70 tokens)
299
+ //model: you can use any model that's on huggingface and has serverless inference enabled. Specify in vendor/modelId format, ex: stabilityai/stable-diffusion-3-medium-diffusers
300
+ //width: in pixels, optional, defaults to 1024
301
+ //height: in pixels, optional, defaults to 1024
302
+ //please note: individual models will have different limits for width and height... some older models cap out at 512 or 768. If your image gen requests are failing, try lowering width and height
303
+
304
+ //The GET version defaults to an image response format (returns the binary content of the image directly)
305
+ //This enables the creation of HTML, markdown, and other types of hypertext documents with "self-generating images" that call this API declaratively... no code needed
306
+
307
+ //For example:
308
+ //<h1>Welcome To Bob's Pet Store</h1>
309
+ //<img class="hero" src="https://defactofficial-mmapi-2.hf.space/api/generate/image?prompt=A%20large%20hamster&model=stabilityai/stable-diffusion-3-medium-diffusers" />
310
+ //
311
+ //In addition to saving you lots of time and money when used as a substitute for stock photography, it also means your text-only LLMs just got multimodal superpowers
312
+ //Check this:
313
+
314
  app.get('/api/generate/image', async (req, res) => {
315
  const responseFormat = req.query.response_format || 'image';
316
  await generateImage(req.query, res, responseFormat)