mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-06-30 04:30:38 +02:00
more inputs for tts
This commit is contained in:
@ -11,6 +11,7 @@ from nostr_dvm.utils.definitions import EventDefinitions
|
|||||||
from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config
|
from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config
|
||||||
from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag
|
from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag
|
||||||
from nostr_dvm.utils.output_utils import upload_media_to_hoster
|
from nostr_dvm.utils.output_utils import upload_media_to_hoster
|
||||||
|
from nostr_dvm.utils.nostr_utils import get_event_by_id, get_referenced_event_by_id
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This File contains a Module to generate Audio based on an input and a voice
|
This File contains a Module to generate Audio based on an input and a voice
|
||||||
@ -57,8 +58,18 @@ class TextToSpeech(DVMTaskInterface):
|
|||||||
for tag in event.tags():
|
for tag in event.tags():
|
||||||
if tag.as_vec()[0] == 'i':
|
if tag.as_vec()[0] == 'i':
|
||||||
input_type = tag.as_vec()[2]
|
input_type = tag.as_vec()[2]
|
||||||
if input_type == "text":
|
if input_type == "event":
|
||||||
|
evt = get_event_by_id(tag.as_vec()[1], client=client, config=dvm_config)
|
||||||
|
prompt = evt.content()
|
||||||
|
elif input_type == "text":
|
||||||
prompt = tag.as_vec()[1]
|
prompt = tag.as_vec()[1]
|
||||||
|
elif input_type == "job":
|
||||||
|
evt = get_referenced_event_by_id(event_id=tag.as_vec()[1], client=client,
|
||||||
|
kinds=[EventDefinitions.KIND_NIP90_RESULT_EXTRACT_TEXT,
|
||||||
|
EventDefinitions.KIND_NIP90_RESULT_SUMMARIZE_TEXT,
|
||||||
|
EventDefinitions.KIND_NIP90_RESULT_TRANSLATE_TEXT],
|
||||||
|
dvm_config=dvm_config)
|
||||||
|
prompt = evt.content()
|
||||||
if input_type == "url":
|
if input_type == "url":
|
||||||
input_file = tag.as_vec()[1]
|
input_file = tag.as_vec()[1]
|
||||||
elif tag.as_vec()[0] == 'param':
|
elif tag.as_vec()[0] == 'param':
|
||||||
|
@ -238,7 +238,7 @@ def decrypt_private_zap_message(msg: str, privkey: SecretKey, pubkey: PublicKey)
|
|||||||
return str(ex)
|
return str(ex)
|
||||||
|
|
||||||
|
|
||||||
def zap(lud16: str, amount: int, content, zapped_event: Event, keys, dvm_config, zaptype="public"):
|
def zaprequest(lud16: str, amount: int, content, zapped_event, zapped_user, keys, relay_list, zaptype="public"):
|
||||||
if lud16.startswith("LNURL") or lud16.startswith("lnurl"):
|
if lud16.startswith("LNURL") or lud16.startswith("lnurl"):
|
||||||
url = lnurl.decode(lud16)
|
url = lnurl.decode(lud16)
|
||||||
elif '@' in lud16: # LNaddress
|
elif '@' in lud16: # LNaddress
|
||||||
@ -251,11 +251,16 @@ def zap(lud16: str, amount: int, content, zapped_event: Event, keys, dvm_config,
|
|||||||
callback = ob["callback"]
|
callback = ob["callback"]
|
||||||
encoded_lnurl = lnurl.encode(url)
|
encoded_lnurl = lnurl.encode(url)
|
||||||
amount_tag = Tag.parse(['amount', str(amount * 1000)])
|
amount_tag = Tag.parse(['amount', str(amount * 1000)])
|
||||||
relays_tag = Tag.parse(['relays', str(dvm_config.RELAY_LIST)])
|
relays_tag = Tag.parse(['relays', str(relay_list)])
|
||||||
p_tag = Tag.parse(['p', zapped_event.pubkey().to_hex()])
|
|
||||||
e_tag = Tag.parse(['e', zapped_event.id().to_hex()])
|
|
||||||
lnurl_tag = Tag.parse(['lnurl', encoded_lnurl])
|
lnurl_tag = Tag.parse(['lnurl', encoded_lnurl])
|
||||||
tags = [amount_tag, relays_tag, p_tag, e_tag, lnurl_tag]
|
if zapped_event is not None:
|
||||||
|
p_tag = Tag.parse(['p', zapped_event.pubkey().to_hex()])
|
||||||
|
e_tag = Tag.parse(['e', zapped_event.id().to_hex()])
|
||||||
|
tags = [amount_tag, relays_tag, p_tag, e_tag, lnurl_tag]
|
||||||
|
else:
|
||||||
|
p_tag = Tag.parse(['p', zapped_user.to_hex()])
|
||||||
|
tags = [amount_tag, relays_tag, p_tag, lnurl_tag]
|
||||||
|
|
||||||
|
|
||||||
if zaptype == "private":
|
if zaptype == "private":
|
||||||
key_str = keys.secret_key().to_hex() + zapped_event.id().to_hex() + str(zapped_event.created_at().as_secs())
|
key_str = keys.secret_key().to_hex() + zapped_event.id().to_hex() + str(zapped_event.created_at().as_secs())
|
||||||
@ -281,7 +286,6 @@ def zap(lud16: str, amount: int, content, zapped_event: Event, keys, dvm_config,
|
|||||||
print(e)
|
print(e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_price_per_sat(currency):
|
def get_price_per_sat(currency):
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@ -325,6 +329,8 @@ def make_ln_address_nostdress(identifier, npub, pin, nostdressdomain):
|
|||||||
return "", ""
|
return "", ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def check_and_set_ln_bits_keys(identifier, npub):
|
def check_and_set_ln_bits_keys(identifier, npub):
|
||||||
if not os.getenv("LNBITS_INVOICE_KEY_" + identifier.upper()):
|
if not os.getenv("LNBITS_INVOICE_KEY_" + identifier.upper()):
|
||||||
invoicekey, adminkey, walletid, userid, success = create_lnbits_account(identifier)
|
invoicekey, adminkey, walletid, userid, success = create_lnbits_account(identifier)
|
||||||
|
Reference in New Issue
Block a user