File size: 1,150 Bytes
7274bc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)