text-to-speech / db /load_db.py
Daryl Fung
added audio database and query
0fd4a4d
raw
history blame
527 Bytes
from sentence_transformers import SentenceTransformer
# Connect using a MilvusClient object
from pymilvus import Collection
from db_connect import connect, disconnect
#
with open('responses.txt', 'r') as file:
content = file.read()
contents = content.split('\n\n')
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
embeddings = model.encode(contents)
data = [
contents,
embeddings
]
connect()
collection = Collection("Response")
collection.insert(data)
collection.flush()
disconnect()