Package: openlrc
Open-LyricsOpen-Lyrics is a Python library that transcribes voice files usingfaster-whisper, and translates/polishes the resulting text
into.lrcfiles in the desired language usingOpenAI-GPT.InstallationPlease install CUDA 11.x andcuDNN 8 for CUDA 11first according tohttps://opennmt.net/CTranslate2/installation.htmlto enablefaster-whisper.faster-whisperalso needscuBLAS for CUDA 11installed.For Windows Users (click to expand)(For Windows Users only) Windows user can Download the libraries from Purfview's repository:Purfview'swhisper-standalone-winprovides the required NVIDIA libraries for Windows in asingle archive. Decompress the archive and place the libraries in a directory included in thePATH.Add yourOpenAI API keyto environment variableOPENAI_API_KEY.InstallPyTorch:pipinstalltorchtorchvisiontorchaudio--index-urlhttps://download.pytorch.org/whl/cu118Install latestfast-whisperpipinstallgit+https://github.com/guillaumekln/faster-whisperInstallffmpegand addbindirectory
to yourPATH.This project can be installed from PyPI:pipinstallopenlrcor install directly from GitHub:pipinstallgit+https://github.com/zh-plus/Open-LyricsUsagefromopenlrcimportLRCerif__name__=='__main__':lrcer=LRCer()# Single filelrcer.run('./data/test.mp3',target_lang='zh-cn')# Generate translated ./data/test.lrc with default translate prompt.# Multiple fileslrcer.run(['./data/test1.mp3','./data/test2.mp3'],target_lang='zh-cn')# Note we run the transcription sequentially, but run the translation concurrently for each file.# Path can contain videolrcer.run(['./data/test_audio.mp3','./data/test_video.mp4'],target_lang='zh-cn')# Generate translated ./data/test_audio.lrc and ./data/test_video.srt# Use context.yaml to improve translationlrcer.run('./data/test.mp3',target_lang='zh-cn',context_path='./data/context.yaml')# To skip translation processlrcer.run('./data/test.mp3',target_lang='en',skip_trans=True)# Change asr_options or vad_options, check openlrc.defaults for detailsvad_options={"threshold":0.1}lrcer=LRCer(vad_options=vad_options)lrcer.run('./data/test.mp3',target_lang='zh-cn')# Enhance the audio using noise suppression (consume more time).lrcer.run('./data/test.mp3',target_lang='zh-cn',noise_suppress=True)Check more details inDocumentation.ContextUtilize the available context to enhance the quality of your translation.
Save them ascontext.yamlin the same directory as your audio file.[!NOTE]
The improvement of translation quality from Context isNOTguaranteed.background:"Thisisamulti-linebackground.Thisisabasicexample."audio_type:Moviedescription_map:{movie_name1 (without extension):"Thisisamulti-linedescriptionformovie1.",movie_name2 (without extension):"Thisisamulti-linedescriptionformovie2.",movie_name3 (without extension):"Thisisasingle-linedescriptionformovie3.",}Todo[Efficiency] Batched translate/polish for GPT request (enable contextual ability).[Efficiency] Concurrent support for GPT request.[Translation Quality] Make translate prompt more robust according tohttps://github.com/openai/openai-cookbook.[Feature] Automatically fix json encoder error using GPT.[Efficiency] Asynchronously perform transcription and translation for multiple audio inputs.[Quality] Improve batched translation/polish prompt according
togpt-subtrans.[Feature] Input video support.[Feature] Multiple output format support.[Quality] Speech enhancement for input audio.[Feature] Preprocessor: Voice-music separation.[Feature] Align ground-truth transcription with audio.[Quality]
Usemultilingual language modelto assess
translation quality.[Efficiency] Add Azure OpenAI Service support.[Quality] Useclaudefor translation.[Feature] Add local LLM support.[Feature] Multiple translate engine (Microsoft, DeepL, Google, etc.) support.[Feature] Build
aelectron + fastapiGUI for cross-platform application.Addfine-tuned whisper-large-v2models for common
languages.[Others] Add transcribed examples.SongPodcastAudiobookCreditshttps://github.com/guillaumekln/faster-whisperhttps://github.com/m-bain/whisperXhttps://github.com/openai/openai-pythonhttps://github.com/openai/whisperhttps://github.com/machinewrapped/gpt-subtranshttps://github.com/MicrosoftTranslator/Text-Translation-API-V3-PythonStar History