-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump version to 0.3.0: Merge pull request #5 from atomiechen/dev
Bump version to 0.3.0
- Loading branch information
Showing
12 changed files
with
392 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import requests | ||
from urllib.parse import urlparse | ||
import os | ||
import time | ||
|
||
|
||
def get_filename_from_url(download_url): | ||
# Parse the URL. | ||
parsed_url = urlparse(download_url) | ||
# The last part of the path is usually the filename. | ||
filename = os.path.basename(parsed_url.path) | ||
return filename | ||
|
||
def download_binary(download_url, file_path=None, dir='.'): | ||
response = requests.get(download_url, allow_redirects=True) | ||
if file_path == None: | ||
filename = get_filename_from_url(download_url) | ||
if filename == '' or filename == None: | ||
filename = 'download_' + time.strftime("%Y%m%d_%H%M%S") | ||
file_path = os.path.abspath(os.path.join(dir, filename)) | ||
# Open the file in binary mode and write to it. | ||
with open(file_path, "wb") as file: | ||
file.write(response.content) | ||
return file_path | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from handyllm import OpenAIAPI | ||
|
||
from dotenv import load_dotenv, find_dotenv | ||
# load env parameters from file named .env | ||
# API key is read from environment variable OPENAI_API_KEY | ||
# organization is read from environment variable OPENAI_ORGANIZATION | ||
load_dotenv(find_dotenv()) | ||
|
||
file_path = 'hello.m4a' | ||
|
||
with open(file_path, "rb") as file_bin: | ||
response = OpenAIAPI.audio_transcriptions( | ||
file=file_bin, | ||
model='whisper-1', | ||
# timeout=10, | ||
) | ||
print(response['text']) |
File renamed without changes.
Oops, something went wrong.