text-to-speech / app.py
Daryl Fung
added batch
59da368
raw
history blame
552 Bytes
from fastapi import FastAPI
import uvicorn
import faiss
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
index = faiss.IndexFlatL2(model.get_sentence_embedding_dimension()) # build the index
index.add(model.encode(['hello']))
app = FastAPI()
@app.post('/tts')
async def transcribe(text: str):
embeddings = model.encode([text])
# store the text to a file
return embeddings[0]
if __name__ == '__main__':
uvicorn.run('app:app', host='0.0.0.0', port=7860)