check length of input text for per unit calculation

This commit is contained in:
Believethehype 2023-12-29 17:58:07 +01:00
parent f4c1e834c6
commit 89939fc15a
3 changed files with 13 additions and 12 deletions

View File

@ -334,7 +334,8 @@ class DVM:
user = get_or_add_user(self.dvm_config.DB, original_event.pubkey().to_hex(),
client=self.client, config=self.dvm_config)
print(user.lud16 + " " + str(amount))
bolt11 = zaprequest(user.lud16, amount, "Couldn't finish job, returning sats", original_event,
bolt11 = zaprequest(user.lud16, amount, "Couldn't finish job, returning sats",
original_event,
self.keys, self.dvm_config, zaptype="private")
if bolt11 is None:
print("Receiver has no Lightning address, can't zap back.")
@ -477,12 +478,12 @@ class DVM:
python_location = "/bin/python"
if platform == "win32":
python_location = "/Scripts/python"
python_bin = ( r'cache/venvs/' + os.path.basename(dvm_config.SCRIPT).split(".py")[0]
+ python_location)
python_bin = (r'cache/venvs/' + os.path.basename(dvm_config.SCRIPT).split(".py")[0]
+ python_location)
retcode = subprocess.call([python_bin, dvm_config.SCRIPT,
'--request', json.dumps(request_form),
'--identifier', dvm_config.IDENTIFIER,
'--output', 'output.txt'])
'--request', json.dumps(request_form),
'--identifier', dvm_config.IDENTIFIER,
'--output', 'output.txt'])
print("Finished processing, loading data..")
with open(os.path.abspath('output.txt')) as f:
@ -492,8 +493,8 @@ class DVM:
if line != '\n':
result += line
os.remove(os.path.abspath('output.txt'))
else: #Some components might have issues with running code in otuside venv.
# We install locally in these cases for now
else: # Some components might have issues with running code in otuside venv.
# We install locally in these cases for now
result = dvm.process(request_form)
try:
post_processed = dvm.post_process(str(result), job_event)

View File

@ -24,7 +24,8 @@ Outputs: Generated Audiofile
class TextToSpeech(DVMTaskInterface):
KIND: int = EventDefinitions.KIND_NIP90_TEXT_TO_SPEECH
TASK: str = "text-to-speech"
FIX_COST: float = 200
FIX_COST: float = 20
PER_UNIT_COST = 0.1
dependencies = [("nostr-dvm", "nostr-dvm"),
("TTS", "TTS==0.22.0")]

View File

@ -20,8 +20,7 @@ def input_data_file_duration(event, dvm_config, client, start=0, end=0):
input_type = tag.as_vec()[2]
if input_type == "text":
# For now, ignore length of any text, just return 1.
return 1
return len(input_value)
if input_type == "event": # NIP94 event
evt = get_event_by_id(input_value, client=client, config=dvm_config)
@ -29,7 +28,7 @@ def input_data_file_duration(event, dvm_config, client, start=0, end=0):
input_value, input_type = check_nip94_event_for_media(evt, input_value, input_type)
if input_type == "text":
# For now, ingore length of any text, just return 1.
return 1
return len(input_value)
if input_type == "url":
source_type = check_source_type(input_value)