Skip to content

Commit

Permalink
Merge branch 'master' into SD2-948-fix-all-edenai-apis-failing-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Daggx committed Dec 16, 2024
2 parents aece85b + f6b698f commit 38fc585
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 113 deletions.
26 changes: 15 additions & 11 deletions edenai_apis/apis/openai/openai_audio_api.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import base64
from io import BytesIO
import json
import uuid
from typing import Optional, List
from io import BytesIO
from typing import List, Optional

import requests

from edenai_apis.apis.amazon.helpers import check_webhook_result
from edenai_apis.features import AudioInterface
from edenai_apis.features.audio import TextToSpeechDataClass
from edenai_apis.features.audio.speech_to_text_async.speech_to_text_async_dataclass import (
SpeechDiarization,
SpeechToTextAsyncDataClass,
)
from edenai_apis.utils.exception import ProviderException
from edenai_apis.utils.types import (
AsyncBaseResponseType,
AsyncLaunchJobResponseType,
AsyncResponseType,
AsyncPendingResponseType,
AsyncResponseType,
ResponseType,
)
from edenai_apis.features.audio.speech_to_text_async.speech_to_text_async_dataclass import (
SpeechDiarization,
SpeechToTextAsyncDataClass,
)
from edenai_apis.features import AudioInterface
from edenai_apis.utils.exception import ProviderException
from edenai_apis.utils.upload_s3 import USER_PROCESS, upload_file_bytes_to_s3

from edenai_apis.utils.upload_s3 import upload_file_bytes_to_s3, USER_PROCESS
from .helpers import convert_tts_audio_rate


Expand Down Expand Up @@ -94,7 +96,9 @@ def audio__speech_to_text_async__get_job_result(
)

if not result_object or not result_object.get("content"):
raise ProviderException("Provider returned an empty response")
return AsyncPendingResponseType[SpeechToTextAsyncDataClass](
provider_job_id=provider_job_id
)

try:
original_response = json.loads(result_object["content"]).get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
"original_response": {
"status": "success",
"request": {
"id": "req_h4tygWOFSudQCj175YtZg",
"timestamp": 1727355854.923456,
"operations": 1
"id": "req_hxh471xetrcprHdR1JA8z",
"timestamp": 1733997971.431954,
"operations": 5
},
"type": {
"deepfake": 0.01
},
"media": {
"id": "med_h4tyD5FNLdWjes2V36427",
"uri": "https://cdn.discordapp.com/attachments/1285184350261870694/1288046848560463892/tom-cruise_Deepfake2.jpeg?ex=66f6659b&is=66f5141b&hm=0eeade51129487243fddf2424f17e5cf24f640a4ecade235d87c1dab8c7e442b&"
"id": "med_hxh4iySbajnOdOjLyN5fm",
"uri": "face.jpeg"
}
},
"standardized_response": {
"ai_score": 0.99,
"prediction": "ai-generated"
"deepfake_score": 0.01,
"prediction": "original"
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"status": "succeeded",
"provider_job_id": "med_h4tlkcZQ7f5ESX90CuvvZ",
"provider_job_id": "med_hxi8793QP0QtlupBIssg3",
"original_response": {
"media": {
"id": "med_h4tlkcZQ7f5ESX90CuvvZ",
"uri": "https://d14uq1pz7dzsdq.cloudfront.net/4f8f3bb1-b322-4ef3-a166-da641d37d746_/tmp/tmp08h_rdxu.upload.mp4?Expires=1727709680&Signature=DmyYhOaki-tGoHz2QT1ekCk7B0iDBuaHQbX6kpwUM9m1WlEZqbxAN0uqDruu0g7f3i8OrUProh1Kgi91H4HciN0s74o80P8QAd7LjQmBM86aLedvAaoeGeBJis3dXQrj2jHtMyohq~yf1mRi57YbCdxcI5jxtcWUWVEdtmHi0vFGuINhWMymaFGnrKcvEXRFNdTrwpWt9Hs6mVqX9xbYuVd0UFUo1wTyFoYwL4FGbSh7tXLljsItAL7BfB5LKjMryMiD4kTe3NGOBIxPtDRfiw2FKXK0ij2ksTPeHyA3vUaB--3~l6GCIYoUS5RXyNc-GLpuCNdLb5baY8wKrumrOQ__&Key-Pair-Id=K1F55BTI9AHGIK"
"id": "med_hxi8793QP0QtlupBIssg3",
"uri": "faces.mp4"
},
"request": "req_h4tltii7O4PVL5g3rp7ib",
"request": "req_hxi8C8jlhfj4XLi0h1adt",
"data": {
"status": "finished",
"started": 1727355075.403806,
"last_update": 1727355077.599314,
"operations": 8,
"started": 1734001929.112691,
"last_update": 1734001930.762513,
"operations": 40,
"progress": 1,
"frames": [
{
"info": {
"id": "med_h4tlkcZQ7f5ESX90CuvvZ_1",
"id": "med_hxi8793QP0QtlupBIssg3_1",
"position": 0
},
"type": {
Expand All @@ -25,7 +25,7 @@
},
{
"info": {
"id": "med_h4tlkcZQ7f5ESX90CuvvZ_2",
"id": "med_hxi8793QP0QtlupBIssg3_2",
"position": 2000
},
"type": {
Expand All @@ -34,7 +34,7 @@
},
{
"info": {
"id": "med_h4tlkcZQ7f5ESX90CuvvZ_3",
"id": "med_hxi8793QP0QtlupBIssg3_3",
"position": 4000
},
"type": {
Expand All @@ -43,7 +43,7 @@
},
{
"info": {
"id": "med_h4tlkcZQ7f5ESX90CuvvZ_4",
"id": "med_hxi8793QP0QtlupBIssg3_4",
"position": 6000
},
"type": {
Expand All @@ -52,7 +52,7 @@
},
{
"info": {
"id": "med_h4tlkcZQ7f5ESX90CuvvZ_5",
"id": "med_hxi8793QP0QtlupBIssg3_5",
"position": 8000
},
"type": {
Expand All @@ -61,7 +61,7 @@
},
{
"info": {
"id": "med_h4tlkcZQ7f5ESX90CuvvZ_6",
"id": "med_hxi8793QP0QtlupBIssg3_6",
"position": 10000
},
"type": {
Expand All @@ -70,7 +70,7 @@
},
{
"info": {
"id": "med_h4tlkcZQ7f5ESX90CuvvZ_7",
"id": "med_hxi8793QP0QtlupBIssg3_7",
"position": 12000
},
"type": {
Expand All @@ -79,7 +79,7 @@
},
{
"info": {
"id": "med_h4tlkcZQ7f5ESX90CuvvZ_8",
"id": "med_hxi8793QP0QtlupBIssg3_8",
"position": 14000
},
"type": {
Expand All @@ -94,42 +94,42 @@
"prediction": "original",
"details_per_frame": [
{
"position": 0,
"position": 0.0,
"score": 0.001,
"prediction": "original"
},
{
"position": 2000,
"position": 2000.0,
"score": 0.001,
"prediction": "original"
},
{
"position": 4000,
"position": 4000.0,
"score": 0.001,
"prediction": "original"
},
{
"position": 6000,
"position": 6000.0,
"score": 0.001,
"prediction": "original"
},
{
"position": 8000,
"position": 8000.0,
"score": 0.001,
"prediction": "original"
},
{
"position": 10000,
"position": 10000.0,
"score": 0.001,
"prediction": "original"
},
{
"position": 12000,
"position": 12000.0,
"score": 0.001,
"prediction": "original"
},
{
"position": 14000,
"position": 14000.0,
"score": 0.001,
"prediction": "original"
}
Expand Down
Loading

0 comments on commit 38fc585

Please sign in to comment.