Skip to content

Commit

Permalink
fixes related to creating folders
Browse files Browse the repository at this point in the history
  • Loading branch information
believethehype committed Dec 17, 2023
1 parent 2adc87d commit 79deb24
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
14 changes: 8 additions & 6 deletions nostr_dvm/tasks/texttospeech.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
from pathlib import Path
import urllib.request

from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface
from nostr_dvm.utils.admin_utils import AdminConfig
Expand All @@ -21,7 +22,7 @@
class TextToSpeech(DVMTaskInterface):
KIND: int = EventDefinitions.KIND_NIP90_TEXT_TO_SPEECH
TASK: str = "text-to-speech"
FIX_COST: float = 0
FIX_COST: float = 200
dependencies = [("nostr-dvm", "nostr-dvm"),
("TTS", "TTS==0.22.0")]

Expand All @@ -46,10 +47,10 @@ def create_request_from_nostr_event(self, event, client=None, dvm_config=None):
if self.options.get("input_file") and self.options.get("input_file") != "":
input_file = self.options['input_file']
else:
input_file = "https://media.nostr.build/av/de104e3260be636533a56fd4468b905c1eb22b226143a997aa936b011122af8a.wav"
import urllib.request
if not Path.exists(Path(r'cache/input.wav')):
urllib.request.urlretrieve(input_file, "cache/input.wav")
if not Path.exists(Path('cache/input.wav')):
input_file_url = "https://media.nostr.build/av/de104e3260be636533a56fd4468b905c1eb22b226143a997aa936b011122af8a.wav"
urllib.request.urlretrieve(input_file_url, "cache/input.wav")
input_file = "cache/input.wav"
language = "en"

for tag in event.tags():
Expand Down Expand Up @@ -86,7 +87,7 @@ def process(self, request_form):

tts.tts_to_file(
text=options["prompt"],
speaker_wav="cache/input.wav", language=options["language"], file_path="outputs/output.wav")
speaker_wav=options["input_wav"], language=options["language"], file_path="outputs/output.wav")
result = upload_media_to_hoster("outputs/output.wav")
return result
except Exception as e:
Expand All @@ -101,6 +102,7 @@ def build_example(name, identifier, admin_config):
dvm_config = build_default_config(identifier)
admin_config.LUD16 = dvm_config.LN_ADDRESS

#use an alternative local wav file you want to use for cloning
options = {'input_file': ""}

nip89info = {
Expand Down
6 changes: 4 additions & 2 deletions nostr_dvm/utils/database_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ class User:
def create_sql_table(db):
try:
import os
if not os.path.exists(r'.\db'):
os.makedirs(r'.\db')
if not os.path.exists(r'db'):
os.makedirs(r'db')
if not os.path.exists(r'outputs'):
os.makedirs(r'outputs')
con = sqlite3.connect(db)
cur = con.cursor()
cur.execute(""" CREATE TABLE IF NOT EXISTS users (
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '0.0.4'
VERSION = '0.0.5'
DESCRIPTION = 'A framework to build and run NIP90 Data Vending Machines'
LONG_DESCRIPTION = ('A framework to build and run NIP90 Data Vending Machines. '
'This is an early stage release. Interfaces might change/brick')
Expand Down
4 changes: 2 additions & 2 deletions tests/test_dvm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def nostr_client():
#nostr_client_test_translation("note1p8cx2dz5ss5gnk7c59zjydcncx6a754c0hsyakjvnw8xwlm5hymsnc23rs", "event", "es", 20,20)
#nostr_client_test_translation("44a0a8b395ade39d46b9d20038b3f0c8a11168e67c442e3ece95e4a1703e2beb", "event", "zh", 20, 20)
#nostr_client_test_image("a beautiful purple ostrich watching the sunset")
nostr_client_test_tts("Hello, this is a test. One two three.")
nostr_client_test_tts("Hello, this is a test. Mic check one, two.")


#cashutoken = "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJpZCI6InZxc1VRSVorb0sxOSIsImFtb3VudCI6MSwiQyI6IjAyNWU3ODZhOGFkMmExYTg0N2YxMzNiNGRhM2VhMGIyYWRhZGFkOTRiYzA4M2E2NWJjYjFlOTgwYTE1NGIyMDA2NCIsInNlY3JldCI6InQ1WnphMTZKMGY4UElQZ2FKTEg4V3pPck5rUjhESWhGa291LzVzZFd4S0U9In0seyJpZCI6InZxc1VRSVorb0sxOSIsImFtb3VudCI6NCwiQyI6IjAyOTQxNmZmMTY2MzU5ZWY5ZDc3MDc2MGNjZmY0YzliNTMzMzVmZTA2ZGI5YjBiZDg2Njg5Y2ZiZTIzMjVhYWUwYiIsInNlY3JldCI6IlRPNHB5WE43WlZqaFRQbnBkQ1BldWhncm44UHdUdE5WRUNYWk9MTzZtQXM9In0seyJpZCI6InZxc1VRSVorb0sxOSIsImFtb3VudCI6MTYsIkMiOiIwMmRiZTA3ZjgwYmMzNzE0N2YyMDJkNTZiMGI3ZTIzZTdiNWNkYTBhNmI3Yjg3NDExZWYyOGRiZDg2NjAzNzBlMWIiLCJzZWNyZXQiOiJHYUNIdHhzeG9HM3J2WWNCc0N3V0YxbU1NVXczK0dDN1RKRnVwOHg1cURzPSJ9XSwibWludCI6Imh0dHBzOi8vbG5iaXRzLmJpdGNvaW5maXhlc3RoaXMub3JnL2Nhc2h1L2FwaS92MS9ScDlXZGdKZjlxck51a3M1eVQ2SG5rIn1dfQ=="
Expand All @@ -162,7 +162,7 @@ def handle(self, relay_url, event):
print(f"Received new event from {relay_url}: {event.as_json()}")
if event.kind() == 7000:
print("[Nostr Client]: " + event.as_json())
elif event.kind() > 6000 and event.kind() < 6999:
elif 6000 < event.kind() < 6999:
print("[Nostr Client]: " + event.as_json())
print("[Nostr Client]: " + event.content())

Expand Down

0 comments on commit 79deb24

Please sign in to comment.