Skip to content

Commit

Permalink
Merge pull request #2 from vatsalaggarwal/vatsal/fix_bug
Browse files Browse the repository at this point in the history
fix: resolve "| None" by using typing.Optional
  • Loading branch information
vatsalaggarwal authored Apr 11, 2023
2 parents 833900e + ebbdd79 commit abaecca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "whisper-cli"
version = "0.0.4"
version = "0.0.5"
description = "A command-line interface for transcribing and translating audio using OpenAI's Whisper API"
authors = ["Vatsal <[email protected]>"]
license = "MIT"
Expand Down
15 changes: 8 additions & 7 deletions whisper_cli/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import openai
from typing import Optional
import typer
from rich import print

Expand All @@ -15,7 +16,7 @@ def get_file_type(file_name: str) -> str:
return file_name.split(".")[-1]


def _check_response_format(response_format: str | None):
def _check_response_format(response_format: Optional[str]):
if response_format is None:
return None
elif response_format in ["json", "srt", "verbose_json", "vtt"]:
Expand Down Expand Up @@ -53,7 +54,7 @@ def get_api_key(env: str = "default") -> str:
)


def show_result(result, response_format: str | None):
def show_result(result, response_format: Optional[str]):
"""Show result."""
if response_format is None:
response_format = "json"
Expand All @@ -68,10 +69,10 @@ def show_result(result, response_format: str | None):
def transcribe(
file_name: str,
model: str = "whisper-1",
prompt: str | None = None,
response_format: str | None = None,
prompt: Optional[str] = None,
response_format: Optional[str] = None,
temperature: float = 0,
language: str | None = None,
language: Optional[str] = None,
):
"""Transcribe audio file using whisper."""
openai.api_key = get_api_key()
Expand All @@ -93,8 +94,8 @@ def transcribe(
def translate(
file_name: str,
model: str = "whisper-1",
prompt: str | None = None,
response_format: str | None = None,
prompt: Optional[str] = None,
response_format: Optional[str] = None,
temperature: float = 0,
):
"""Translate audio file using whisper."""
Expand Down

0 comments on commit abaecca

Please sign in to comment.