marquesafonso commited on
Commit
d7fa99f
·
1 Parent(s): 1cd29a5

move config to variables and secrets

Browse files
Files changed (4) hide show
  1. README.md +1 -1
  2. main.py +1 -2
  3. utils/api_configs.py +0 -6
  4. utils/transcriber.py +4 -5
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🐢
4
  colorFrom: purple
5
  colorTo: green
6
  sdk: docker
7
- pinned: false
8
  license: cc-by-nc-4.0
9
  ---
10
 
 
4
  colorFrom: purple
5
  colorTo: green
6
  sdk: docker
7
+ pinned: true
8
  license: cc-by-nc-4.0
9
  ---
10
 
main.py CHANGED
@@ -12,7 +12,6 @@ from pydantic import BaseModel, field_validator
12
 
13
  app = FastAPI()
14
  security = HTTPBasic()
15
- api_configs_file = os.path.abspath("api_config.yml")
16
 
17
  class MP4Video(BaseModel):
18
  video_file: UploadFile
@@ -106,7 +105,7 @@ async def process_video_api(video_file: MP4Video = Depends(),
106
  return Response(content = zip_file)
107
  with open(os.path.join(temp_dir, f"{video_file.filename.split('.')[0]}.srt"), 'w+b') as temp_srt_file:
108
  logging.info("Processing the video...")
109
- output_path, srt_path = process_video(temp_file.name, None, task, max_words_per_line, fontsize, font, bg_color, text_color, caption_mode, api_configs_file)
110
  logging.info("Zipping response...")
111
  with open(os.path.join(temp_dir, f"{video_file.filename.split('.')[0]}.zip"), 'w+b') as temp_zip_file:
112
  zip_file = zip_response(temp_zip_file.name, [output_path, srt_path])
 
12
 
13
  app = FastAPI()
14
  security = HTTPBasic()
 
15
 
16
  class MP4Video(BaseModel):
17
  video_file: UploadFile
 
105
  return Response(content = zip_file)
106
  with open(os.path.join(temp_dir, f"{video_file.filename.split('.')[0]}.srt"), 'w+b') as temp_srt_file:
107
  logging.info("Processing the video...")
108
+ output_path, srt_path = process_video(temp_file.name, None, task, max_words_per_line, fontsize, font, bg_color, text_color, caption_mode)
109
  logging.info("Zipping response...")
110
  with open(os.path.join(temp_dir, f"{video_file.filename.split('.')[0]}.zip"), 'w+b') as temp_zip_file:
111
  zip_file = zip_response(temp_zip_file.name, [output_path, srt_path])
utils/api_configs.py DELETED
@@ -1,6 +0,0 @@
1
- import yaml
2
-
3
- def api_configs(config_file):
4
- with open(config_file, 'r') as f:
5
- db_config = yaml.safe_load(f)
6
- return db_config["api_config"]
 
 
 
 
 
 
 
utils/transcriber.py CHANGED
@@ -1,11 +1,10 @@
 
1
  from gradio_client import Client, handle_file
2
- from utils.api_configs import api_configs
3
 
4
  def transcriber(invideo_file:str, srt_file:str,
5
- max_words_per_line:int, task:str,
6
- config_file:str):
7
- HF_TOKEN = api_configs(config_file)["secrets"]["hf-token"]
8
- HF_SPACE = api_configs(config_file)["secrets"]["hf-space"]
9
  client = Client(HF_SPACE, hf_token=HF_TOKEN)
10
  result = client.predict(
11
  video_input=handle_file(invideo_file),
 
1
+ import os
2
  from gradio_client import Client, handle_file
 
3
 
4
  def transcriber(invideo_file:str, srt_file:str,
5
+ max_words_per_line:int, task:str):
6
+ HF_TOKEN = os.getenv("hf_token")
7
+ HF_SPACE = os.getenv("hf_space")
 
8
  client = Client(HF_SPACE, hf_token=HF_TOKEN)
9
  result = client.predict(
10
  video_input=handle_file(invideo_file),