mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-06-10 19:50:49 +02:00
check length of input text for per unit calculation
This commit is contained in:
parent
f4c1e834c6
commit
89939fc15a
@ -334,7 +334,8 @@ class DVM:
|
|||||||
user = get_or_add_user(self.dvm_config.DB, original_event.pubkey().to_hex(),
|
user = get_or_add_user(self.dvm_config.DB, original_event.pubkey().to_hex(),
|
||||||
client=self.client, config=self.dvm_config)
|
client=self.client, config=self.dvm_config)
|
||||||
print(user.lud16 + " " + str(amount))
|
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")
|
self.keys, self.dvm_config, zaptype="private")
|
||||||
if bolt11 is None:
|
if bolt11 is None:
|
||||||
print("Receiver has no Lightning address, can't zap back.")
|
print("Receiver has no Lightning address, can't zap back.")
|
||||||
@ -477,12 +478,12 @@ class DVM:
|
|||||||
python_location = "/bin/python"
|
python_location = "/bin/python"
|
||||||
if platform == "win32":
|
if platform == "win32":
|
||||||
python_location = "/Scripts/python"
|
python_location = "/Scripts/python"
|
||||||
python_bin = ( r'cache/venvs/' + os.path.basename(dvm_config.SCRIPT).split(".py")[0]
|
python_bin = (r'cache/venvs/' + os.path.basename(dvm_config.SCRIPT).split(".py")[0]
|
||||||
+ python_location)
|
+ python_location)
|
||||||
retcode = subprocess.call([python_bin, dvm_config.SCRIPT,
|
retcode = subprocess.call([python_bin, dvm_config.SCRIPT,
|
||||||
'--request', json.dumps(request_form),
|
'--request', json.dumps(request_form),
|
||||||
'--identifier', dvm_config.IDENTIFIER,
|
'--identifier', dvm_config.IDENTIFIER,
|
||||||
'--output', 'output.txt'])
|
'--output', 'output.txt'])
|
||||||
print("Finished processing, loading data..")
|
print("Finished processing, loading data..")
|
||||||
|
|
||||||
with open(os.path.abspath('output.txt')) as f:
|
with open(os.path.abspath('output.txt')) as f:
|
||||||
@ -492,8 +493,8 @@ class DVM:
|
|||||||
if line != '\n':
|
if line != '\n':
|
||||||
result += line
|
result += line
|
||||||
os.remove(os.path.abspath('output.txt'))
|
os.remove(os.path.abspath('output.txt'))
|
||||||
else: #Some components might have issues with running code in otuside venv.
|
else: # Some components might have issues with running code in otuside venv.
|
||||||
# We install locally in these cases for now
|
# We install locally in these cases for now
|
||||||
result = dvm.process(request_form)
|
result = dvm.process(request_form)
|
||||||
try:
|
try:
|
||||||
post_processed = dvm.post_process(str(result), job_event)
|
post_processed = dvm.post_process(str(result), job_event)
|
||||||
|
@ -24,7 +24,8 @@ Outputs: Generated Audiofile
|
|||||||
class TextToSpeech(DVMTaskInterface):
|
class TextToSpeech(DVMTaskInterface):
|
||||||
KIND: int = EventDefinitions.KIND_NIP90_TEXT_TO_SPEECH
|
KIND: int = EventDefinitions.KIND_NIP90_TEXT_TO_SPEECH
|
||||||
TASK: str = "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"),
|
dependencies = [("nostr-dvm", "nostr-dvm"),
|
||||||
("TTS", "TTS==0.22.0")]
|
("TTS", "TTS==0.22.0")]
|
||||||
|
|
||||||
|
@ -20,8 +20,7 @@ def input_data_file_duration(event, dvm_config, client, start=0, end=0):
|
|||||||
input_type = tag.as_vec()[2]
|
input_type = tag.as_vec()[2]
|
||||||
|
|
||||||
if input_type == "text":
|
if input_type == "text":
|
||||||
# For now, ignore length of any text, just return 1.
|
return len(input_value)
|
||||||
return 1
|
|
||||||
|
|
||||||
if input_type == "event": # NIP94 event
|
if input_type == "event": # NIP94 event
|
||||||
evt = get_event_by_id(input_value, client=client, config=dvm_config)
|
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)
|
input_value, input_type = check_nip94_event_for_media(evt, input_value, input_type)
|
||||||
if input_type == "text":
|
if input_type == "text":
|
||||||
# For now, ingore length of any text, just return 1.
|
# For now, ingore length of any text, just return 1.
|
||||||
return 1
|
return len(input_value)
|
||||||
|
|
||||||
if input_type == "url":
|
if input_type == "url":
|
||||||
source_type = check_source_type(input_value)
|
source_type = check_source_type(input_value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user