Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,51 @@ import numpy as np
|
|
12 |
from TTS.utils.manage import ModelManager
|
13 |
from TTS.utils.synthesizer import Synthesizer
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
@st.experimental_singleton
|
16 |
def get_db_firestore():
|
17 |
cred = credentials.Certificate('test.json')
|
|
|
12 |
from TTS.utils.manage import ModelManager
|
13 |
from TTS.utils.synthesizer import Synthesizer
|
14 |
|
15 |
+
# PersistDataset -----
|
16 |
+
import os
|
17 |
+
import csv
|
18 |
+
import gradio as gr
|
19 |
+
from gradio import inputs, outputs
|
20 |
+
import huggingface_hub
|
21 |
+
from huggingface_hub import Repository, hf_hub_download, upload_file
|
22 |
+
from datetime import datetime
|
23 |
+
|
24 |
+
# created new dataset as awacke1/MindfulStory.csv
|
25 |
+
DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/MindfulStory.csv"
|
26 |
+
DATASET_REPO_ID = "awacke1/MindfulStory.csv"
|
27 |
+
DATA_FILENAME = "MindfulStory.csv"
|
28 |
+
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
29 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
30 |
+
# Download dataset repo using hub download
|
31 |
+
try:
|
32 |
+
hf_hub_download(
|
33 |
+
repo_id=DATASET_REPO_ID,
|
34 |
+
filename=DATA_FILENAME,
|
35 |
+
cache_dir=DATA_DIRNAME,
|
36 |
+
force_filename=DATA_FILENAME
|
37 |
+
)
|
38 |
+
except:
|
39 |
+
print("file not found")
|
40 |
+
def AIMemory(name: str, message: str):
|
41 |
+
if name and message:
|
42 |
+
with open(DATA_FILE, "a") as csvfile:
|
43 |
+
writer = csv.DictWriter(csvfile, fieldnames=["name", "message", "time"])
|
44 |
+
writer.writerow({"name": name, "message": message, "time": str(datetime.now())})
|
45 |
+
commit_url = repo.push_to_hub()
|
46 |
+
return {"name": name, "message": message, "time": str(datetime.now())}
|
47 |
+
|
48 |
+
with open('Mindfulness.txt', 'r') as file:
|
49 |
+
context = file.read()
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
# Set up cloned dataset from repo for operations
|
54 |
+
repo = Repository(
|
55 |
+
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
56 |
+
)
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
@st.experimental_singleton
|
61 |
def get_db_firestore():
|
62 |
cred = credentials.Certificate('test.json')
|