fixes related to creating folders

This commit is contained in:
Believethehype
2023-12-17 22:28:05 +01:00
parent 2adc87d925
commit 79deb2495c
4 changed files with 15 additions and 11 deletions

View File

@ -2,6 +2,7 @@ import json
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
@ -21,7 +22,7 @@ Outputs: Generated Audiofile
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")]
@ -46,10 +47,10 @@ class TextToSpeech(DVMTaskInterface):
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():
@ -86,7 +87,7 @@ class TextToSpeech(DVMTaskInterface):
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:
@ -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 = {

View File

@ -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 (

View File

@ -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')

View File

@ -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=="
@ -162,7 +162,7 @@ def nostr_client():
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())