@@ -938,17 +938,14 @@ async def redact_audio_direct(
938938 """
939939 # Validate file type
940940 if not file .filename :
941- raise HTTPException (
942- status_code = 400 ,
943- detail = "Filename is required"
944- )
941+ raise HTTPException (status_code = 400 , detail = "Filename is required" )
945942
946943 # Check file extension
947944 file_ext = file .filename .lower ().split ("." )[- 1 ]
948945 if file_ext not in {"mp3" , "wav" , "ogg" , "m4a" , "flac" , "aac" , "webm" }:
949946 raise HTTPException (
950947 status_code = 400 ,
951- detail = f"Unsupported file type: .{ file_ext } . Supported: mp3, wav, ogg, m4a, flac, aac, webm"
948+ detail = f"Unsupported file type: .{ file_ext } . Supported: mp3, wav, ogg, m4a, flac, aac, webm" ,
952949 )
953950
954951 # Validate content type if provided
@@ -960,7 +957,7 @@ async def redact_audio_direct(
960957 if not api_key :
961958 raise HTTPException (
962959 status_code = 503 ,
963- detail = "Audio redaction service unavailable: GOOGLE_API_KEY or GEMINI_API_KEY not configured"
960+ detail = "Audio redaction service unavailable: GOOGLE_API_KEY or GEMINI_API_KEY not configured" ,
964961 )
965962
966963 try :
@@ -988,7 +985,9 @@ async def redact_audio_direct(
988985 output_format = output_format ,
989986 )
990987
991- logger .info (f"Audio redaction complete: { response .segments_censored } segments censored" )
988+ logger .info (
989+ f"Audio redaction complete: { response .segments_censored } segments censored"
990+ )
992991
993992 return {
994993 "censored_audio" : response .censored_audio ,
@@ -1015,19 +1014,15 @@ async def redact_audio_direct(
10151014 logger .error (f"Missing dependency: { e } " )
10161015 raise HTTPException (
10171016 status_code = 503 ,
1018- detail = f"Audio redaction service unavailable: missing dependency ({ str (e )} ). Make sure pydub and ffmpeg are installed."
1017+ detail = f"Audio redaction service unavailable: missing dependency ({ str (e )} ). Make sure pydub and ffmpeg are installed." ,
10191018 ) from e
10201019 except ValueError as e :
10211020 logger .error (f"Audio redaction failed: { e } " )
1022- raise HTTPException (
1023- status_code = 400 ,
1024- detail = str (e )
1025- ) from e
1021+ raise HTTPException (status_code = 400 , detail = str (e )) from e
10261022 except Exception as e :
10271023 logger .error (f"Audio redaction failed: { e } " , exc_info = True )
10281024 raise HTTPException (
1029- status_code = 500 ,
1030- detail = f"Audio redaction failed: { str (e )} "
1025+ status_code = 500 , detail = f"Audio redaction failed: { str (e )} "
10311026 ) from e
10321027
10331028
@@ -1043,24 +1038,20 @@ async def redact_audio_download(
10431038 """
10441039 # Validate file type
10451040 if not file .filename :
1046- raise HTTPException (
1047- status_code = 400 ,
1048- detail = "Filename is required"
1049- )
1041+ raise HTTPException (status_code = 400 , detail = "Filename is required" )
10501042
10511043 file_ext = file .filename .lower ().split ("." )[- 1 ]
10521044 if file_ext not in {"mp3" , "wav" , "ogg" , "m4a" , "flac" , "aac" , "webm" }:
10531045 raise HTTPException (
1054- status_code = 400 ,
1055- detail = f"Unsupported file type: .{ file_ext } "
1046+ status_code = 400 , detail = f"Unsupported file type: .{ file_ext } "
10561047 )
10571048
10581049 # Check for API key
10591050 api_key = os .environ .get ("GOOGLE_API_KEY" ) or os .environ .get ("GEMINI_API_KEY" )
10601051 if not api_key :
10611052 raise HTTPException (
10621053 status_code = 503 ,
1063- detail = "Audio redaction service unavailable: GOOGLE_API_KEY or GEMINI_API_KEY not configured"
1054+ detail = "Audio redaction service unavailable: GOOGLE_API_KEY or GEMINI_API_KEY not configured" ,
10641055 )
10651056
10661057 try :
@@ -1110,24 +1101,18 @@ async def redact_audio_download(
11101101 return Response (
11111102 content = censored_audio_bytes ,
11121103 media_type = content_type ,
1113- headers = {
1114- "Content-Disposition" : f'attachment; filename="{ output_name } "'
1115- }
1104+ headers = {"Content-Disposition" : f'attachment; filename="{ output_name } "' },
11161105 )
11171106
11181107 except ImportError as e :
11191108 raise HTTPException (
11201109 status_code = 503 ,
1121- detail = f"Audio redaction service unavailable: missing dependency ({ str (e )} )"
1110+ detail = f"Audio redaction service unavailable: missing dependency ({ str (e )} )" ,
11221111 ) from e
11231112 except ValueError as e :
1124- raise HTTPException (
1125- status_code = 400 ,
1126- detail = str (e )
1127- ) from e
1113+ raise HTTPException (status_code = 400 , detail = str (e )) from e
11281114 except Exception as e :
11291115 logger .error (f"Audio redaction failed: { e } " , exc_info = True )
11301116 raise HTTPException (
1131- status_code = 500 ,
1132- detail = f"Audio redaction failed: { str (e )} "
1133- ) from e
1117+ status_code = 500 , detail = f"Audio redaction failed: { str (e )} "
1118+ ) from e
0 commit comments