lang-id-voxlingua107-ecapa / test_handler_files.py
apenasissso's picture
process from file and fix short audios
7274bc5
raw
history blame
1.15 kB
import json
from handler import EndpointHandler
# init handler
my_handler = EndpointHandler()
import os
# Specify the folder path here
folder_path = (
"/Users/apenasisso/pl/pl-bots/notebooks/analytics/data/elevenlabs_analysis"
)
# List all files in the folder
for filename in os.listdir(folder_path):
full_filename = os.path.join(folder_path, filename)
if os.path.isfile(full_filename) and full_filename.endswith(".wav"):
print(full_filename)
holiday_payload = {
"inputs": f"file://{full_filename}"
# "inputs": "https://pl-bots-public-media.s3.amazonaws.com/5527999790371_8825d2c9-d87b-49c3-bf70-cb536328ba92.mp3"
}
full_filename_json = full_filename.replace(".wav", ".json")
if os.path.isfile(full_filename_json):
print("file exists", full_filename_json)
continue
# test the handler
payload = my_handler(holiday_payload)
# save payload to file
with open(full_filename_json, "w") as outfile:
json.dump(payload, outfile, indent=4)
# show results
print("holiday_payload", payload)