{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "API_KEY = \"YHI5AIKD4BEJ5M0C6U06I00OMHMT6LS0L7T2JD4T\"" ] }, { "cell_type": "code", "execution_count": 201, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "import requests\n", "\n", "\n", "url = \"https://api.runpod.ai/v2/j1mslgsrh55pco/run\"\n", "\n", "headers = {\n", " \"Authorization\": f\"Bearer {API_KEY}\",\n", "}\n", "\n", "payload = {\n", " \"input\": {\n", " # \"song_url\": \"https://voice-gen-audios.s3.eu-north-1.amazonaws.com/combined_trimmed_original.mp3\",\n", " \"song_url\": \"https://voice-gen-audios.s3.eu-north-1.amazonaws.com/Fall_In_Love_Alone.mp3\",\n", " \"user_id\": \"test_user\",\n", " # \"voice_model_url\": \"https://rvc-models.s3.amazonaws.com/lilbaby.pth\"\n", " \"voice_model_id\": \"kanye\"\n", " },\n", " \"webhook\": \"https://webhook.site/1aa04d7d-dd1e-4483-8d6e-86a7faf64559\"\n", "}\n", "\n", "init_response = requests.request(\"POST\", url, headers=headers, json=payload)\n", "\n", "print(init_response)" ] }, { "cell_type": "code", "execution_count": 202, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'id': '44573504-c43a-4ba4-8136-2f209a8a375f', 'status': 'IN_QUEUE'}" ] }, "execution_count": 202, "metadata": {}, "output_type": "execute_result" } ], "source": [ "init_response.json()" ] }, { "cell_type": "code", "execution_count": 207, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'delayTime': 7189,\n", " 'executionTime': 35187,\n", " 'id': '44573504-c43a-4ba4-8136-2f209a8a375f',\n", " 'output': {'combined_url': 'https://voice-gen-audios.s3.eu-north-1.amazonaws.com/f23d6757-9655-4ff0-8922-18ae2f047549.mp3',\n", " 'output_voice_url': 'https://voice-gen-audios.s3.eu-north-1.amazonaws.com/f23d6757-9655-4ff0-8922-18ae2f047549-generated-voical.mp3',\n", " 'time_taken_generation': 7.608142137527466,\n", " 'time_taken_splitting': 16.734182596206665,\n", " 'user_id': 'test_user'},\n", " 'status': 'COMPLETED'}" ] }, "execution_count": 207, "metadata": {}, "output_type": "execute_result" } ], "source": [ "status = f\"https://api.runpod.ai/v2/j1mslgsrh55pco/status/{init_response.json()['id']}\"\n", "# status = f\"https://api.runpod.ai/v2/pzkoh97t2lcm3p/status/04216e5f-d661-410c-9ebc-3d2ab310375a\"\n", "\n", "status_response = requests.request(\"GET\", status, headers=headers)\n", "status_response.json()" ] }, { "cell_type": "code", "execution_count": 175, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "import requests\n", "\n", "\n", "url = \"https://api.runpod.ai/v2/pzkoh97t2lcm3p/run\"\n", "\n", "headers = {\n", " \"Authorization\": f\"Bearer {API_KEY}\",\n", "}\n", "\n", "payload = {\n", " \"input\": {\n", " \"song_url\": \"https://voice-gen-audios.s3.eu-north-1.amazonaws.com/combined_trimmed_original.mp3\",\n", " \"user_id\": \"test_user\",\n", " # \"voice_model_url\": \"https://rvc-models.s3.amazonaws.com/lilbaby.pth\"\n", " \"voice_model_id\": \"kanye\"\n", " },\n", " \"webhook\": \"https://webhook.site/1aa04d7d-dd1e-4483-8d6e-86a7faf64559\"\n", "}\n", "\n", "init_response = requests.request(\"POST\", url, headers=headers, json=payload)\n", "\n", "print(init_response)" ] }, { "cell_type": "code", "execution_count": 176, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'id': 'e0409508-7dca-4514-95c2-92737e54f94e', 'status': 'IN_QUEUE'}" ] }, "execution_count": 176, "metadata": {}, "output_type": "execute_result" } ], "source": [ "init_response.json()" ] }, { "cell_type": "code", "execution_count": 180, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'delayTime': 36093,\n", " 'executionTime': 19256,\n", " 'id': 'e0409508-7dca-4514-95c2-92737e54f94e',\n", " 'output': {'combined_url': 'https://voice-gen-audios.s3.eu-north-1.amazonaws.com/987ca6ed-3148-4812-9b51-27ada7f4cdb0.mp3',\n", " 'output_voice_url': 'https://voice-gen-audios.s3.eu-north-1.amazonaws.com/987ca6ed-3148-4812-9b51-27ada7f4cdb0-generated-voice.wav',\n", " 'time_taken_generation': 5.0794689655303955,\n", " 'time_taken_splitting': 8.448604106903076,\n", " 'user_id': 'test_user'},\n", " 'status': 'COMPLETED'}" ] }, "execution_count": 180, "metadata": {}, "output_type": "execute_result" } ], "source": [ "status = f\"https://api.runpod.ai/v2/pzkoh97t2lcm3p/status/{init_response.json()['id']}\"\n", "# status = f\"https://api.runpod.ai/v2/pzkoh97t2lcm3p/status/04216e5f-d661-410c-9ebc-3d2ab310375a\"\n", "\n", "status_response = requests.request(\"GET\", status, headers=headers)\n", "status_response.json()" ] }, { "cell_type": "code", "execution_count": 264, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " {'id': '759af4bb-8657-43d7-9193-579e2e0f8b80', 'status': 'IN_QUEUE'}\n" ] } ], "source": [ "url = \"https://api.runpod.ai/v2/shnabtayd2o51c/run\"\n", "\n", "headers = {\n", " \"Authorization\": f\"Bearer {API_KEY}\",\n", "}\n", "\n", "payload = {\n", " \"input\": {\n", " \"vocal_url\": \"https://storage.googleapis.com/moises-production--developer/orchestrator/9c064513-14be-4a88-a428-2c1375890f2e/707b5cc1-aa52-419c-a9b5-fb6ebeba2d72/My%20job%20123--lead-voc.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=731360694588-compute%40developer.gserviceaccount.com%2F20230502%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230502T090616Z&X-Goog-Expires=518400&X-Goog-SignedHeaders=host&X-Goog-Signature=4ed2c62d529bb0b0047c4625636ddeab1ebacea1722c28ff0f064917a9997a27448caa68c3f5a9a3bf915bb3cabf159dcbfa0066c89344bc7936a8ec1c8ffa9e0d78fc3f118a0dba28fbdb24e601a53b161f082eacf321eb007bbf6cdac26745a7c4bab07cc79bb824e16e7b6c6de20ccbbf5e51191f0a7cbfca198250e2b494addbeb8c23bdf1539381e3f69f578f0e1753b01de045b3547c5139a5af3977d7a5895b89b2acc75c0923023be30f7cf3cb4b431dc49b940a8afd15e84de9681561d5520daf9a7a547d8fd63dc61ec256155b5252853b77e12810094141d57ee3c3ff74bb33ac570afd1e87fb6f49a32598f834ec581955f9dbc648b023922264\",\n", " \"instrumental_url\": \"https://storage.googleapis.com/moises-production--developer/orchestrator/9c064513-14be-4a88-a428-2c1375890f2e/707b5cc1-aa52-419c-a9b5-fb6ebeba2d72/My%20job%20123--other.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=731360694588-compute%40developer.gserviceaccount.com%2F20230502%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230502T090616Z&X-Goog-Expires=518400&X-Goog-SignedHeaders=host&X-Goog-Signature=3f24f302be1ea0dde6ad0cde94d36853477ff8d7fd14f7fd8265c462d01774417eea834fc85d279eb77caa0ea8fe960643cf79761665de3e5f113f70196b882db0e4311841c3836f71aacfe602a8117a1ec6bd437aceadc43f6838f430cd986b320583cb049419e4bcbe4f07cf7703e9cc71f26c49633cf4385f4d86673ab60af4ceb58726d4d3406bfa1aa9e672dd16c6d6ec70c2c14d5a19d02f8c9603259b4224b7e0002819c559ecf6af63e7e14cb8389a1ef9bd751e4d2368e4f0c70606964e36072fccd94cfe12d81bd2eec81a0926b84bf33c70f2c207c822b015ebf51662c2fd453f6dff3adc875da5558e7da8aea09c0719a6479a97149fee065493\",\n", " \"user_id\": \"test_user\",\n", " \"voice_model_id\": \"kanye\"\n", " },\n", " \"webhook\": \"https://webhook.site/1aa04d7d-dd1e-4483-8d6e-86a7faf64559\"\n", "}\n", "\n", "init_response = requests.request(\"POST\", url, headers=headers, json=payload)\n", "print(init_response, init_response.json())" ] }, { "cell_type": "code", "execution_count": 266, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'delayTime': 167819,\n", " 'executionTime': 17795,\n", " 'id': '759af4bb-8657-43d7-9193-579e2e0f8b80',\n", " 'output': {'combined_url': 'https://voice-gen-audios.s3.eu-north-1.amazonaws.com/fee02930-a07e-4fcb-9b3b-ca94032ad58a.mp3',\n", " 'output_voice_url': 'https://voice-gen-audios.s3.eu-north-1.amazonaws.com/fee02930-a07e-4fcb-9b3b-ca94032ad58a-generated-voice.wav',\n", " 'time_taken_generation': 7.378969192504883,\n", " 'user_id': 'test_user'},\n", " 'status': 'COMPLETED'}" ] }, "execution_count": 266, "metadata": {}, "output_type": "execute_result" } ], "source": [ "headers = {\n", " \"Authorization\": f\"Bearer {API_KEY}\",\n", "}\n", "status = f\"https://api.runpod.ai/v2/shnabtayd2o51c/status/{init_response.json()['id']}\"\n", "status_response = requests.request(\"GET\", status, headers=headers)\n", "status_response.json()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import requests\n", "from voice_generation import generate_wav\n", "import boto3\n", "import os\n", "import uuid\n", "from pydub import AudioSegment\n", "import time\n", "\n", "\n", "AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')\n", "AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')\n", "\n", "\n", "models = {\n", " 'kanye': 'weights/kanye.pth',\n", " 'rose-bp': 'weights/rose-bp.pth',\n", " 'jungkook': 'weights/jungkook.pth',\n", " 'iu': 'weights/iu.pth',\n", " 'drake': 'weights/drake.pth',\n", " 'ariana-grande': 'weights/ariana-grande.pth'\n", "}\n", "\n", "\n", "print('run handler. Removed 2nd gen')\n", "\n", "\n", "def combine_audio(voice_path, instrumental_path):\n", " audio1 = AudioSegment.from_file(instrumental_path)\n", " audio2 = AudioSegment.from_file(voice_path)\n", " \n", " length = max(len(audio1), len(audio2))\n", " audio1 = audio1 + AudioSegment.silent(duration=length - len(audio1))\n", " audio2 = audio2 + AudioSegment.silent(duration=length - len(audio2))\n", " \n", " combined = audio1.overlay(audio2)\n", " \n", " combined.export(\"combined.mp3\", format=\"mp3\")\n", "\n", "\n", "def upload_file_to_s3(local_file_path, s3_file_path):\n", " bucket_name = 'voice-gen-audios'\n", " s3 = boto3.client('s3', aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY)\n", " try:\n", " s3.upload_file(local_file_path, bucket_name, s3_file_path)\n", " return {\"url\": f\"https://{bucket_name}.s3.eu-north-1.amazonaws.com/{s3_file_path}\"}\n", " except boto3.exceptions.S3UploadFailedError as e:\n", " return {\"error\": f\"failed to upload file {local_file_path} to s3 as {s3_file_path}\"}\n", "\n", "\n", "def clean_up_files(remove_voice_model=False):\n", " files = [\n", " \"instrumental.mp3\",\n", " \"vocal.mp3\",\n", " \"output_voice.wav\",\n", " \"combined.mp3\",\n", " ]\n", " if remove_voice_model:\n", " files.append(\"voice_model.pth\")\n", " for file in files:\n", " try:\n", " os.remove(file)\n", " except FileNotFoundError:\n", " return {\"error\": f\"failed to remove file {file}\"}\n", " return {\"success\": \"files removed successfully\"}\n", "\n", "\n", "def get_voice_model(event):\n", " voice_model_id = event[\"input\"].get(\"voice_model_id\", \"\")\n", " voice_model_url = event[\"input\"].get(\"voice_model_url\", \"\")\n", " \n", " if not voice_model_url and not voice_model_id:\n", " return {\"error\": \"voice_model_url or voice_model_id is required\"}\n", "\n", " if voice_model_id and voice_model_id not in models:\n", " return {\"error\": \"model not found in pre-loaded models\"}\n", " \n", " if voice_model_id:\n", " return {\"model_path\": models[voice_model_id]}\n", " \n", " print(\"downloading voice_model\")\n", " voice_model_response = requests.get(voice_model_url)\n", " if voice_model_response.status_code != 200:\n", " return {\"error\": f\"failed to download voice_model, error: {voice_model_response.text}\"}\n", " \n", " with open(\"voice_model.pth\", \"wb\") as f:\n", " f.write(voice_model_response.content)\n", "\n", " return {\"model_path\": \"voice_model.pth\"}\n", "\n", "\n", "def handler(event):\n", " print(event)\n", " file_id = str(uuid.uuid4())\n", " user_id = event[\"input\"].get(\"user_id\", \"not provided\")\n", " \n", " if not AWS_ACCESS_KEY_ID or not AWS_SECRET_ACCESS_KEY:\n", " return {\"error\": \"AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are missing from environment variables\"}\n", " \n", " voice_model = get_voice_model(event)\n", " if \"error\" in voice_model:\n", " return voice_model.get(\"error\")\n", "\n", " vocal_url = event[\"input\"].get(\"vocal_url\", \"\")\n", " if vocal_url == \"\":\n", " return {\"error\": \"vocal_url is required\"}\n", " \n", " instrumental_url = event[\"input\"].get(\"instrumental_url\", \"\")\n", " if instrumental_url == \"\":\n", " return {\"error\": \"instrumental_url is required\"}\n", " \n", " vocal_file = requests.get(vocal_url)\n", " if vocal_file.status_code != 200:\n", " return {\"error\": \"failed to download vocal_file\"}\n", " with open(\"vocal.mp3\", \"wb\") as f:\n", " f.write(vocal_file.content)\n", " \n", " instrumental_file = requests.get(instrumental_url)\n", " if instrumental_file.status_code != 200:\n", " return {\"error\": \"failed to download instrumental_file\"}\n", " with open(\"instrumental.mp3\", \"wb\") as f:\n", " f.write(instrumental_file.content)\n", " \n", " generation_start = time.time() # remove after testing\n", "\n", " generation = generate_wav(\n", " audio_file='vocal.mp3',\n", " method='pm',\n", " index_rate=0.6,\n", " output_file='output_voice.wav',\n", " model_path=voice_model.get(\"model_path\")\n", " )\n", " generation_end = time.time() # remove after testing\n", " time_taken_generation = generation_end - generation_start # remove after testing\n", " print(f\"generation took {time_taken_generation} seconds\") # remove after testing\n", " if \"error\" in generation:\n", " return generation.get(\"error\")\n", "\n", " combine_audio(\"output_voice.wav\", \"instrumental.mp3\")\n", "\n", " if not os.path.exists(\"combined.mp3\"):\n", " return {\"error\": \"failed to combine audio\"}\n", "\n", " combined = upload_file_to_s3(\"combined.mp3\", f\"{file_id}.mp3\")\n", " output_voice = upload_file_to_s3(\"output_voice.wav\", f\"{file_id}-generated-voice.wav\")\n", "\n", " if combined_error := combined.get(\"error\"):\n", " return combined_error\n", " \n", " if output_voice_error := output_voice.get(\"error\"):\n", " return output_voice_error\n", " \n", " combined_url = combined.get(\"url\")\n", " output_voice_url = output_voice.get(\"url\")\n", "\n", " need_to_remove_voice_model = False\n", " if voice_model.get(\"model_path\") == \"voice_model.pth\":\n", " need_to_remove_voice_model = True\n", " cleanup_result = clean_up_files(need_to_remove_voice_model)\n", " if cleanup_error := cleanup_result.get(\"error\"):\n", " return cleanup_error\n", "\n", " return {\n", " \"combined_url\": combined_url,\n", " \"output_voice_url\": output_voice_url,\n", " \"user_id\": user_id,\n", " \"time_taken_generation\": time_taken_generation, # remove after testing\n", " }\n", "\n", "\n", "result = handler({\n", " \"input\": {\n", " \"vocal_url\": \"https://storage.googleapis.com/moises-production--developer/orchestrator/9c064513-14be-4a88-a428-2c1375890f2e/707b5cc1-aa52-419c-a9b5-fb6ebeba2d72/My%20job%20123--lead-voc.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=731360694588-compute%40developer.gserviceaccount.com%2F20230502%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230502T090616Z&X-Goog-Expires=518400&X-Goog-SignedHeaders=host&X-Goog-Signature=4ed2c62d529bb0b0047c4625636ddeab1ebacea1722c28ff0f064917a9997a27448caa68c3f5a9a3bf915bb3cabf159dcbfa0066c89344bc7936a8ec1c8ffa9e0d78fc3f118a0dba28fbdb24e601a53b161f082eacf321eb007bbf6cdac26745a7c4bab07cc79bb824e16e7b6c6de20ccbbf5e51191f0a7cbfca198250e2b494addbeb8c23bdf1539381e3f69f578f0e1753b01de045b3547c5139a5af3977d7a5895b89b2acc75c0923023be30f7cf3cb4b431dc49b940a8afd15e84de9681561d5520daf9a7a547d8fd63dc61ec256155b5252853b77e12810094141d57ee3c3ff74bb33ac570afd1e87fb6f49a32598f834ec581955f9dbc648b023922264\",\n", " \"instrumental_url\": \"https://storage.googleapis.com/moises-production--developer/orchestrator/9c064513-14be-4a88-a428-2c1375890f2e/707b5cc1-aa52-419c-a9b5-fb6ebeba2d72/My%20job%20123--other.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=731360694588-compute%40developer.gserviceaccount.com%2F20230502%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230502T090616Z&X-Goog-Expires=518400&X-Goog-SignedHeaders=host&X-Goog-Signature=3f24f302be1ea0dde6ad0cde94d36853477ff8d7fd14f7fd8265c462d01774417eea834fc85d279eb77caa0ea8fe960643cf79761665de3e5f113f70196b882db0e4311841c3836f71aacfe602a8117a1ec6bd437aceadc43f6838f430cd986b320583cb049419e4bcbe4f07cf7703e9cc71f26c49633cf4385f4d86673ab60af4ceb58726d4d3406bfa1aa9e672dd16c6d6ec70c2c14d5a19d02f8c9603259b4224b7e0002819c559ecf6af63e7e14cb8389a1ef9bd751e4d2368e4f0c70606964e36072fccd94cfe12d81bd2eec81a0926b84bf33c70f2c207c822b015ebf51662c2fd453f6dff3adc875da5558e7da8aea09c0719a6479a97149fee065493\",\n", " \"user_id\": \"test_user\",\n", " \"voice_model_id\": \"kanye\"\n", " }\n", "})\n", "\n", "print(result)" ] }, { "cell_type": "code", "execution_count": 192, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'weights/kanye.pth'" ] }, "execution_count": 192, "metadata": {}, "output_type": "execute_result" } ], "source": [ "models = {\n", " 'kanye': 'weights/kanye.pth',\n", " 'rose-bp': 'weights/rose-bp.pth',\n", " 'jungkook': 'weights/jungkook.pth',\n", " 'iu': 'weights/iu.pth',\n", " 'drake': '',\n", " 'ariana-grande': 'weights/ariana-grande.pth'\n", "}\n", "\n", "# \"kanye\" in models\n", "\n", "model_to_choose = \"kanye\"\n", "\n", "model = models[model_to_choose]\n", "model" ] }, { "cell_type": "code", "execution_count": 238, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\"jobId\":\"c4d0b8ef-e59f-4316-b5bb-668cac368576\",\"id\":\"c4d0b8ef-e59f-4316-b5bb-668cac368576\"}\n" ] } ], "source": [ "import requests\n", "\n", "url = \"https://developer-api.moises.ai/api/job\"\n", "\n", "payload = {\n", "\t\"name\": \"My job 123\",\n", "\t\"workflow\": \"test\",\n", "\t\"params\": {\"inputUrl\": \"https://tmi-audios.s3.amazonaws.com/Eminem+-+Lose+Yourself+(Lyrics).wav\"}\n", "}\n", "headers = {\n", "\t\"Authorization\": \"6236e441-99ab-4ea4-a35a-a4e9e6bbad76\",\n", "\t\"Content-Type\": \"application/json\"\n", "}\n", "\n", "init_response = requests.request(\"POST\", url, json=payload, headers=headers)\n", "\n", "print(init_response.text)" ] }, { "cell_type": "code", "execution_count": 241, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'id': 'c4d0b8ef-e59f-4316-b5bb-668cac368576', 'app': 'Default Application', 'workflow': 'test', 'status': 'SUCCEEDED', 'batchName': None, 'workflowParams': {'inputUrl': 'https://tmi-audios.s3.amazonaws.com/Eminem+-+Lose+Yourself+(Lyrics).wav'}, 'result': {'other': 'https://storage.googleapis.com/moises-production--developer/orchestrator/3a82e46d-8811-4e39-b662-a65692774cf5/5eefe0e2-ee80-4991-b2d7-b1e2ccf06cfb/My%20job%20123--other.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=731360694588-compute%40developer.gserviceaccount.com%2F20230502%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230502T102210Z&X-Goog-Expires=518401&X-Goog-SignedHeaders=host&X-Goog-Signature=a0290d54c0743198231da803bdd7ccf99d3da928aef8048fe8cdf2688369e6c647c058fde063bac3e61270a1567bba89e426880823bd505f0cbd0b1a30a9f6f9876d8801b7f856c1f9f92063993f6d759e83b0e235cba26e57b3fa2f0234d5a42c9f8fb63cf4a1134cceb88645d39e5b2584f990ae3a6e17eec41018d04b53402a9fb1a1122640b749613d23fc463f9063c9f736eaf87cab7e96774e2a2f7ed7886004b609e481cfcc778d242ff205ad1c0b79ba28cbfa11aa58b8b89274caa34e857d931fdfa72542d6ec34b79c1ebbb2630d5be2109dd4860222c59d0443fcf7be7c42964c743192bb10776757204495daa4009673323020b12c94542a3fc9', 'back-voc': 'https://storage.googleapis.com/moises-production--developer/orchestrator/3a82e46d-8811-4e39-b662-a65692774cf5/5eefe0e2-ee80-4991-b2d7-b1e2ccf06cfb/My%20job%20123--back-voc.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=731360694588-compute%40developer.gserviceaccount.com%2F20230502%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230502T102210Z&X-Goog-Expires=518401&X-Goog-SignedHeaders=host&X-Goog-Signature=4009a8a75b9fc6373538199811f6783d1a28760874275400dd5f24b72583ba799f6550a1cb33426972a777da9bdae27aa183bab5f6e736d2f2b502b0397b0bea5307e256945323f0df1fad4d78f1df7ea780ae581b2095d56f23f4c6c2c21222565ab43b720da13cfda585d519fd8dc1b533d1339dc28f2e2b16fc74729ff2a72ae733fc92e80df5c0a9272ec42280ac7f0ff5f53e619f74b6fd3b64b8eec75d244f7db241fa09204e4f91d61d7ca807643f825b5289b11fa11cf0a016192f5aa2ea36c401f595ad83a61ea6bdebf13e0430ac470b7fdf33ed07f04de4e9859431fa770cfeff7a657b8f062700f99afd24b9990d3fc90aa16360a7569d4cc343', 'lead-voc': 'https://storage.googleapis.com/moises-production--developer/orchestrator/3a82e46d-8811-4e39-b662-a65692774cf5/5eefe0e2-ee80-4991-b2d7-b1e2ccf06cfb/My%20job%20123--lead-voc.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=731360694588-compute%40developer.gserviceaccount.com%2F20230502%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230502T102210Z&X-Goog-Expires=518401&X-Goog-SignedHeaders=host&X-Goog-Signature=c07d624f4d6dca66c938193f9cd9c8becc69fbcbc225c17ee5e0f1154d900aaec57d00d8f298999b87cbfa14ab30cab9b13cd6795eacae74f80ae77f4d767d16f09b7257c0a1203d0b05e6ced2a7d2c20a710d40ec93306f150b05045daf27c35c057f789586efd65e2efd4c502703ec891df06fda5e613e1374738233ba4f4d07378903aacc8304bccb326faedc8947e83280a7f969a7fb69063d73e900fb87acf878180617833465fd5ed7d25e7dca7e3436da4a9e03124434668038d008ac31609d65b745b6e3992c27d2071fc7173cf5d87d18ac1e80b6f9a4c33361553337f033f9418bd12d9af706f91cc2e1664ab7b33ad8eb1e1c688479a5189372ce'}, 'name': 'My job 123', 'createdAt': '2023-05-02T10:19:41.294Z', 'startedAt': '2023-05-02T10:19:41.329Z', 'completedAt': '2023-05-02T10:20:57.219Z'}\n" ] } ], "source": [ "import requests\n", "\n", "url = f\"https://developer-api.moises.ai/api/job/{init_response.json().get('jobId')}\"\n", "\n", "headers = {\"Authorization\": \"6236e441-99ab-4ea4-a35a-a4e9e6bbad76\"}\n", "\n", "response = requests.request(\"GET\", url, headers=headers)\n", "\n", "print(response.json())" ] }, { "cell_type": "code", "execution_count": 245, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "https://storage.googleapis.com/moises-production--developer/orchestrator/3a82e46d-8811-4e39-b662-a65692774cf5/5eefe0e2-ee80-4991-b2d7-b1e2ccf06cfb/My%20job%20123--other.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=731360694588-compute%40developer.gserviceaccount.com%2F20230502%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20230502T102210Z&X-Goog-Expires=518401&X-Goog-SignedHeaders=host&X-Goog-Signature=a0290d54c0743198231da803bdd7ccf99d3da928aef8048fe8cdf2688369e6c647c058fde063bac3e61270a1567bba89e426880823bd505f0cbd0b1a30a9f6f9876d8801b7f856c1f9f92063993f6d759e83b0e235cba26e57b3fa2f0234d5a42c9f8fb63cf4a1134cceb88645d39e5b2584f990ae3a6e17eec41018d04b53402a9fb1a1122640b749613d23fc463f9063c9f736eaf87cab7e96774e2a2f7ed7886004b609e481cfcc778d242ff205ad1c0b79ba28cbfa11aa58b8b89274caa34e857d931fdfa72542d6ec34b79c1ebbb2630d5be2109dd4860222c59d0443fcf7be7c42964c743192bb10776757204495daa4009673323020b12c94542a3fc9\n" ] } ], "source": [ "print(response.json()['result']['other'])" ] }, { "cell_type": "code", "execution_count": 263, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.6" ] }, "execution_count": 263, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def get_method(event):\n", " method = event[\"input\"].get(\"method\", \"pm\")\n", " if method not in [\"pm\", \"harvest\"]:\n", " method = \"pm\"\n", " return method\n", "\n", "\n", "# test\n", "event = {\n", " \"input\": {\n", " \"method\": \"harvest\"\n", " }\n", "}\n", "\n", "get_method(event)\n", "\n", "\n", "def get_index_rate(event):\n", " index_rate = event[\"input\"].get(\"index_rate\", 0.6)\n", " if index_rate < 0 or index_rate > 1:\n", " index_rate = 0.6\n", " return index_rate\n", "\n", "# test\n", "event = {\n", " \"input\": {\n", " \"index_rate\": 1.2\n", " }\n", "}\n", "\n", "get_index_rate(event)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.13" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }