-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from Dadangdut33/dev
- Loading branch information
Showing
117 changed files
with
14,715 additions
and
6,618 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
indent_style=space | ||
indent_size=4 |
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 |
---|---|---|
@@ -1,3 +1,27 @@ | ||
{ | ||
"python.analysis.typeCheckingMode": "basic" | ||
} | ||
"python.languageServer": "Pylance", | ||
"python.analysis.typeCheckingMode": "basic", | ||
"[python]": { | ||
"editor.defaultFormatter": "eeyore.yapf", | ||
"editor.formatOnSave": true, | ||
"editor.formatOnPaste": true, | ||
"editor.formatOnType": false, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": false, | ||
"source.organizeImports": false, | ||
"source.organizeImports.ruff": false, | ||
"source.organizeImports.python": false, | ||
} | ||
}, | ||
"yapf.args": ["--style", "{based_on_style: pep8, indent_width: 4, column_limit: 125, BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF: false, DEDENT_CLOSING_BRACKETS: true}"], | ||
"ruff.enable": true, | ||
"ruff.lint.args": [ | ||
"--line-length", | ||
"125" | ||
], | ||
"ruff.format.args": [ | ||
"--line-length", | ||
"125" | ||
], | ||
"python.analysis.autoImportCompletions": false, | ||
} |
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 was deleted.
Oops, something went wrong.
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,122 @@ | ||
import sys | ||
import os | ||
import shutil | ||
from cx_Freeze import setup, Executable | ||
|
||
sys.setrecursionlimit(5000) | ||
|
||
|
||
def get_env_name(): | ||
return os.path.basename(sys.prefix) | ||
|
||
|
||
def version(): | ||
with open(os.path.join(os.path.dirname(__file__), "speech_translate/_version.py")) as f: | ||
return f.readline().split("=")[1].strip().strip('"').strip("'") | ||
|
||
|
||
# If you get cuda error try to remove your cuda from your system path because cx_freeze will try to include it from there | ||
# instead of the one in the python folder | ||
print(">> Building SpeechTranslate version", version()) | ||
print(">> Environment:", get_env_name()) | ||
|
||
|
||
def clear_dir(dir): | ||
print(">> Clearing", dir) | ||
try: | ||
if not os.path.exists(dir): | ||
return | ||
if os.path.isdir(dir): | ||
for f in os.listdir(dir): | ||
os.remove(os.path.join(dir, f)) | ||
|
||
# remove the folder | ||
os.rmdir(dir) | ||
else: | ||
os.remove(dir) | ||
except Exception as e: | ||
print(f">> Failed to clear {dir} reason: {e}") | ||
|
||
|
||
print(">> Clearing code folder") | ||
clear_dir("./speech_translate/export") | ||
clear_dir("./speech_translate/debug") | ||
clear_dir("./speech_translate/log") | ||
clear_dir("./speech_translate/temp") | ||
print(">> Done") | ||
|
||
folder_name = f"build/SpeechTranslate {version()}" | ||
|
||
build_exe_options = { | ||
"excludes": ["yapf", "ruff"], | ||
"packages": ["torch", "soundfile", "sounddevice", "av"], | ||
"build_exe": folder_name | ||
} | ||
|
||
base = "Win32GUI" if sys.platform == "win32" else None | ||
|
||
setup( | ||
name="SpeechTranslate", | ||
version=version(), | ||
description="Speech Translate", | ||
options={ | ||
"build_exe": build_exe_options, | ||
}, | ||
executables=[ | ||
Executable( | ||
"Run.py", | ||
base=base, | ||
icon="speech_translate/assets/icon.ico", | ||
target_name="SpeechTranslate.exe", | ||
) | ||
], | ||
) | ||
|
||
# check if arg is build_exe | ||
if len(sys.argv) < 2 or sys.argv[1] != "build_exe": | ||
sys.exit(0) | ||
|
||
print(">> Copying some more files...") | ||
|
||
# we need to copy av.libs to foldername/lib because cx_freeze doesn't copy it for some reason | ||
print(">> Copying av.libs to lib folder") | ||
shutil.copytree(f"{get_env_name()}/Lib/site-packages/av.libs", f"{folder_name}/lib/av.libs") | ||
|
||
# copy Lincese as license.txt to build folder | ||
print(">> Creating license.txt to build folder") | ||
with open("LICENSE", "r", encoding="utf-8") as f: | ||
with open(f"{folder_name}/license.txt", "w", encoding="utf-8") as f2: | ||
f2.write(f.read()) | ||
|
||
# copy README.md as README.txt to build folder | ||
print(">> Creating README.txt to build folder") | ||
with open("build/pre_install_note.txt", "r", encoding="utf-8") as f: | ||
with open(f"{folder_name}/README.txt", "w", encoding="utf-8") as f2: | ||
f2.write(f.read()) | ||
|
||
# create version.txt | ||
print(">> Creating version.txt") | ||
with open(f"{folder_name}/version.txt", "w", encoding="utf-8") as f: | ||
f.write(version()) | ||
|
||
# copy install_ffmpeg.ps1 to build folder | ||
print(">> Copying install_ffmpeg.ps1 to build folder") | ||
with open("install_ffmpeg.ps1", "r", encoding="utf-8") as f: | ||
with open(f"{folder_name}/install_ffmpeg.ps1", "w", encoding="utf-8") as f2: | ||
f2.write(f.read()) | ||
|
||
# create link to repo | ||
print(">> Creating link to repo") | ||
with open(f"{folder_name}/homepage.url", "w", encoding="utf-8") as f: | ||
f.write("[InternetShortcut]\n") | ||
f.write("URL=https://github.com/Dadangdut33/Speech-Translate") | ||
|
||
print(">> Opening output folder") | ||
output_folder = os.path.abspath(folder_name) | ||
try: | ||
os.startfile(output_folder) | ||
except Exception: | ||
# linux | ||
import subprocess | ||
|
||
subprocess.call(["xdg-open", output_folder]) |
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,3 @@ | ||
The app has been successfully installed, for more information about its usage please visit the wiki at https://github.com/Dadangdut33/Speech-Translate/wiki. | ||
|
||
For any questions or suggestions, feel free to add any issues or open a discussion on the repository. |
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,20 @@ | ||
Thanks for downloading Speech Translate. | ||
|
||
Speech Translate is a practical application that combines OpenAI's Whisper ASR model with free translation APIs. It serves as a versatile tool for both real-time / live speech-to-text and speech translation, allowing the user to seamlessly convert spoken language into written text. Additionally, it has the option to import and transcribe audio / video files effortlessly. | ||
|
||
Requirements: | ||
- Windows 8.1 or higher for speaker input | ||
- FFmpeg installed in your system (the app will prompt you to install it if you don't have it) | ||
- Internet connection (for translation with API) | ||
- Each whisper model requires the following VRAM: | ||
* tiny (~1 GB) | ||
* base (~1 GB) | ||
* small (~2 GB) | ||
* medium (~5 GB) | ||
* large (~10 GB) | ||
|
||
Whisper can be used with CPU but will be very limited when doing so. It is recommended to use a cuda compatible GPU for better performance. | ||
|
||
Please also note that when using faster-whisper, the speed will be significantly faster and the model size will be reduced depending on the usage. For more information about this please visit https://github.com/guillaumekln/faster-whisper | ||
|
||
For more information about the app, user settings, how to use it, and more please visit the wiki at https://github.com/Dadangdut33/Speech-Translate/wiki |
Oops, something went wrong.