TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #32 · 7 фев.

Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять: from timeit import timeit def t1(): # складываем 10 строк через + из переменной t = 'text' for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t2(): # склеиваем список строк через метод join arr = ['text'] * 10 for _ in range(1000): s = ''.join(arr) def t3(): # складываем через + но не из переменной а непосредственно инлайн объекты for _ in range(1000): s = 'text' + 'text' + 'text' + ... # всего 10 раз Теперь каждую строку склейки запустим по 10М раз >>> timeit(t1, number=10000) 0.21951690399964718 >>> timeit(t2, number=10000) 1.4978306379998685 >>> timeit(t3, number=10000) 0.2213820789993406 Хм, а нам говорили что через "+" это плохо и медленно ))) 😁 Тут стоит учитывать, что речь идёт о склейке множества длинных строк. Давайте изменим условия: def t4(): t = 'text'*100 for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t5(): arr = ['text'*100] * 10 for _ in range(1000): s = ''.join(arr) def t6(): for _ in range(1000): s = 'text'*100 + 'text'*100 + ... # всего 10 раз >>> timeit(t4, number=10000) 12.795130728000004 >>> timeit(t5, number=10000) 2.642637542999182 >>> timeit(t6, number=10000) 0.2184546610005782 Вот, уже другой разговор, сразу видна разница, в среднем в 6 раз. Но погодите, почему последний тест t6() по скорости такой же как и t3()? Ведь строки теперь в 100 раз длиннее! Это вопросы оптимизации кода, какие простые изменения ускоряют или замедляют выполнение программы. Мы столкнулись с примером обхода обращения к переменной. Например, именно так работает директива #define в С++, во время компиляции подставляя значение переменной вместо ссылки на неё. В Python это тоже работает, но часто ли вы сможете встретить такой способ работы со строками? К сожалению, способ почти только теоретический. В целом, тесты показали то, что мы хотели. Делаем выводы самостоятельно. Полный листинг 🌍 #tricks

Резултати

Пронајдени 4 слични објави

Пребарај: #subtitles

当前筛选 #subtitles清除筛选
Libreware

@libreware · Post #1521 · 04.12.2025 г., 15:59

yt-fts - YouTube Full Text Search https://github.com/NotJoeMartinez/yt-fts yt-fts is a command line program that uses yt-dlp to scrape all of a #YouTube channels #subtitles and load them into a sqlite database that is searchable from the command line. It allows you to query a channel for specific key word or phrase and will generate time stamped YouTube urls to the video containing the keyword. It also supports semantic search via the OpenAI embeddings API, Gemini embedding API and using chromadb. Blog Post LLM/RAG Chat Bot Video Summaries Semantic Search CHANGELOG Installation: pip install yt-fts #yt

Уголок кинопереводчика

@AVTranslationcorner · Post #10 · 06.01.2021 г., 13:20

Live #subtitling is an important accessibility tool. Each year, more and more events provide both intralingual and interlingual live #subtitles. We invite you to listen to Łukasz Stanisław Dutka from the University of Warsaw, Poland, an expert in live subtitling and #respeaking, who will disclose some secrets of the profession of a live #subtitler. Just click the link below: https://youtu.be/2He3SuLkEGk

GitHub Trends

@githubtrending · Post #14817 · 11.06.2025 г., 11:30

#python#asr#captions#cli#python#subtitle#subtitles#transcript#transcripts#translating_transcripts#youtube#youtube_api#youtube_asr#youtube_captions#youtube_subtitles#youtube_transcript#youtube_transcripts#youtube_video The YouTube Transcript API is a tool that helps you get the text from YouTube videos. It's fast and easy to use, saving you time compared to watching the whole video. You can use it to make subtitles, translate text, and even analyze what's being said in videos. This is helpful for content creators who want to make their videos more accessible and for researchers who need to study video content quickly. It also supports multiple languages, making it useful for a wide range of users. https://github.com/jdepoix/youtube-transcript-api

GitHub Trends

@githubtrending · Post #15052 · 12.08.2025 г., 13:30

#python#audiobook#audiobooks#content_creation#content_creator#epub_converter#kokoro#kokoro_82m#kokoro_tts#media_generation#narrator#speech_synthesis#subtitles#text_to_audio#text_to_speech#tts#voice_synthesis Abogen is a user-friendly tool that quickly converts ePub, PDF, or text files into natural-sounding audio with synchronized subtitles, perfect for creating audiobooks or voiceovers for social media and other projects. You can customize speech speed, choose or mix voices, generate subtitles by sentence or word, and select various audio and subtitle formats. It supports batch processing with queue mode and lets you save chapters separately or merged. Installation is straightforward on Windows, Mac, and Linux, with options for GPU acceleration. This saves you time and effort in producing high-quality audio content from text files efficiently. https://github.com/denizsafak/abogen