[ebook2audiobook] STT model with gradio / feat.m1 mac
ยท
๐Ÿ› ๏ธ Tools
GitHub - DrewThomasson/ebook2audiobook: Convert ebooks to audiobooks with chapters and metadata using dynamic AI models and voicConvert ebooks to audiobooks with chapters and metadata using dynamic AI models and voice cloning. Supports 1,107+ languages! - DrewThomasson/ebook2audiobookgithub.com ebook2audiobook  ์ „์ž์ฑ…์„ ์ฑ•ํ„ฐ์™€ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ํฌํ•จํ•œ ์˜ค๋””์˜ค๋ถ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. Coqui XTTS์™€ Fairseq๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๊ณ ํ’ˆ์งˆ์˜ ํ…์ŠคํŠธ ์Œ์„ฑ ๋ณ€ํ™˜์„ ์ œ๊ณตํ•˜๋ฉฐ..
[Python] Dunder / Magic Methods (1)
ยท
๐Ÿง‘‍๐Ÿ’ป Develop
Python์—๋Š” ๋‹ค์–‘ํ•œ ๋งค์ง ๋ฉ”์†Œ๋“œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ชจ๋“  ๊ฒƒ์ด ๊ฐ์ฒด๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์–ด ๊ทธ ์•ˆ์— ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜๋Š” ํ˜•์‹์ž…๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์˜ ๋ง์…ˆ์„ ์˜ˆ๋กœ ๋“ค๋ฉด "Hello" + " World"๋ฅผ ์‹คํ–‰ํ•˜๋ฉด "Hello World"๊ฐ€ ๋ฉ๋‹ˆ๋‹ค. "+" ์–ด๋–ป๊ฒŒ ๋ง์…ˆ์ด ์ด๋ฃจ์–ด์ง€๋Š” ๊ฐ€๋Š” ๋ฐ”๋กœ ๋ณ€์ˆ˜์— ์„ ์–ธ๋œ ๊ฐ์ฒด ์•ˆ์— ๋งค์ง ๋ฉ”์†Œ๋“œ๋กœ ์žˆ๋Š” __add__(self, other) ์—ฐ์‚ฐ์ž๊ฐ€ ์žˆ์–ด ๋’ค(other)์— ์˜ค๋Š” ๋ณ€์ˆ˜๋ฅผ ๋”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.  Print functionprint operation์€ __str__ ๋งค์ง ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด ๋ณ€์ˆ˜๋ฅผ ๋ฌธ์ž์—ด๋กœ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค. (=__repr__()), Class์— ๋งค์ง ๋ฉ”์„œ๋“œ๊ฐ€ ์„ ์–ธ๋˜์–ด ์žˆ์ง€ ์•Š๊ฑฐ๋‚˜ string์ด ์•„๋‹Œ ๋‹ค๋ฅธ Type์˜ ๋ณ€์ˆ˜๊ฐ€ return์ด ๋  ๊ฒฝ์šฐ "__str__ returned n..
[Gemini] gemini calculate Tokenize in Locally
ยท
๐Ÿ› ๏ธ Tools
Google VertaxAI Python SDK  gemini tokenizer๋Š” ์›๋ž˜ ๊ณต๊ฐœ๋˜์ง€ ์•Š์•„ token์„ ๊ณ„์‚ฐํ•˜๋ ค๋ฉด API๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š” ๋ฒˆ๊ฑฐ๋กœ์›€์ด ์žˆ์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ Google Cloud Community์— ์งˆ๋ฌธ์„ ๋“ฑ๋กํ–ˆ๋‹ค. ์š”๋Š” tiktoken๊ณผ ๊ฐ™์ด token ๊ณ„์‚ฐ์„ local๋กœ ํ•  ์ˆ˜์žˆ๊ฒŒ ๊ณต๊ฐœํ•ด ๋‹ฌ๋ผ๋Š” ๊ฒƒ์ด์—ˆ๋‹ค. token ์ˆ˜๋ฅผ ์•Œ ์ˆ˜ ์—†์œผ๋ฉด gemini-api๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ max_token์— ๋งž๊ฒŒ ๊ณ„์† ์กฐ์ •ํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ˆ˜ ์ฐจ๋ก€ API๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค. ์ด๋Ÿฐ ๋ฌธ์ œ๋ฅผ ์˜์‹ํ–ˆ๋Š”์ง€ token ์ˆ˜๋ฅผ API๋กœ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ณต๊ฐœํ–ˆ์ง€๋งŒ ๋ฌธ์ œ๋Š” ๋‘ ๋ฒˆ์˜ API ์‚ฌ์šฉ๋„ ๋งˆ์Œ์— ๋“ค์ง€ ์•Š์•˜๋‹ค.   tiktoken์œผ๋กœ OpenAI์—์„œ๋Š” tokenizer์™€ vocab์„ ๊ณต๊ฐœํ•ด ํˆฌ๋ช…ํ•˜๊ฒŒ API ๋น„์šฉ์„ ์ฒญ..
[iMessage] iMessage ๋ถˆ๋Ÿฌ์˜ค๊ธฐ(.py)
ยท
๐Ÿ’ป Mac
iMessage ๊ตฌ์กฐ Macbook์— iphone iMessage๋ฅผ ๋™๊ธฐํ™”ํ•˜๋ฉด ~/Users/Name/Library/Messages ํด๋”์— ์ €์žฅ๋œ๋‹ค. ์ €์žฅ๋œ ํด๋”๋ฅผ ๋ณด๋ฉด .db๋กœ ๊ด€๋ฆฌ๋˜๋Š” ๊ฒƒ์„ ๋ณผ์ˆ˜์žˆ๋‹ค. sqlite๋กœ ์ €์žฅ๋˜๋ฉฐ ๋‹ค์–‘ํ•œ ์ปฌ๋Ÿผ๋“ค์ด ์žˆ๋‹ค.   ์ฃผ์š” ํ…Œ์ด๋ธ”์€ message๋กœ text์™€ attributedBody์—์„œ ๋ฉ”์„ธ์ง€ ๋ณธ๋ฌธ์„ ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค. ๋”๋ณด๊ธฐ- **ROWID**: ๊ฐ ํ–‰(row)์˜ ๊ณ ์œ  ์‹๋ณ„์ž.- **guid**: ๋ฉ”์‹œ์ง€์˜ ์ „์—ญ ๊ณ ์œ  ์‹๋ณ„์ž.- **text**: ๋ฉ”์‹œ์ง€์˜ ๋‚ด์šฉ.- **replace**: ๋Œ€์ฒด ํ…์ŠคํŠธ.- **service_center**: ๋ฉ”์‹œ์ง€๋ฅผ ์ฒ˜๋ฆฌํ•œ ์„œ๋น„์Šค ์„ผํ„ฐ.- **handle_id**: ๋ฉ”์‹œ์ง€์˜ ์†ก์‹ ์ž ๋˜๋Š” ์ˆ˜์‹ ์ž์˜ ID.- **subject**: ๋ฉ”์‹œ์ง€์˜ ์ฃผ์ œ..
[...] ํŒŒ์ด์ฌ ์–ด๋””๊นŒ์ง€ ์•„๋‹ˆ?
ยท
๐Ÿ Python
"..." @abstractmethod     def title(self) -> str: ...    Python์—์„œ ...์€ ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์ƒํ™ฉ์—์„œ ์“ฐ์ด๋Š” ํŠน๋ณ„ํ•œ ๊ฐ์ฒด๋‹ค. ์ฃผ์š” ์šฉ๋„๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.Ellipsis ๊ฐ์ฒด Python์˜ Ellipsis ๊ฐ์ฒด๋Š” ...๋กœ๋„ ํ‘œํ˜„๋œ๋‹ค. ์ด ๊ฐ์ฒด๋Š” ๊ณ ๊ธ‰ ์Šฌ๋ผ์ด์‹ฑ(slicing) ๋ฐ ๋‹ค์ฐจ์› ๋ฐฐ์—ด๊ณผ ๊ฐ™์€ ๊ฒฝ์šฐ์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉ๋œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, NumPy์™€ ๊ฐ™์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—์„œ ๋‹ค์ฐจ์› ๋ฐฐ์—ด์˜ ํŠน์ • ๋ถ€๋ถ„์„ ์Šฌ๋ผ์ด์Šคํ•  ๋•Œ ์œ ์šฉํ•˜๋‹ค.import numpy as nparr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])print(arr[..., 1]) # ๋‹ค์ฐจ์› ๋ฐฐ์—ด์˜ ๋ชจ๋“  ์ฐจ์›์—์„œ 1๋ฒˆ์งธ ์ธ๋ฑ์Šค๋ฅผ ์„ ํƒ  ํ•จ์ˆ˜ ๋ฐ ..
string method. 1~20
ยท
๐Ÿ Python
Python String Methods1) capitalize() : ๋ฌธ์ž์—ด์˜ ์ฒซ ๊ธ€์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ ๋ณ€ํ™˜text: str = "hello"print(text.capitalize()) # Hello2) casefold() : ๋ฌธ์ž์—ด์„ ์†Œ๋ฌธ์ž๋กœ ๋ณ€ํ™˜text1: str = 'MARIo'text2: str = 'maRIO'print(text1.casefold()) # marioprint(text2.casefold()) # marioprint(text1.casefold() == text2.casefold()) # True3) center() : ๋ฌธ์ž์—ด์„ ๊ฐ€์šด๋ฐ ์ •๋ ฌtext: str = "hello"print(text.center(20)) # hello print(text.center(20,..
[Python] f-string trick (2)
ยท
๐Ÿ Python
“Formatted String Literals.” 1) f-string nested in nested python ๋ฒ„์ „์ด ์˜ฌ๋ผ๊ฐ€๋ฉด์„œ ๋‹ค์–‘ํ•˜๊ณ  ํŽธ๋ฆฌํ•œ ๊ธฐ๋Šฅ์ด ๋งŽ์ด ์ƒ๊ฒผ๋‹ค. ๊ทธ ์ค‘ํ•˜๋‚˜์ธ f-string ์•ˆ์— ๋‹ค์‹œ f-string์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์ด๋ ‡๊ฒŒ ๋˜๋ฉด ์•ž์„œ ์†Œ๊ฐœํ•œ f-string trick(1)์˜ datetime์„ ์ž์œ ์ž์žฌ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. from datetime import datetime now : datetime = datetime.now() date_spec : str = "%d.%m.%Y" date = now | date_spec print(f"{now:{date_spec}}") # '17.03.2024' 2) file path file path๋ฅผ ๋ฌธ์ž์—ด๋กœ ์ฒ˜๋ฆฌํ•  ๋•Œ escape ..
[Python] ์ด๊ฑฐ ๋ชจ๋ฅด๋ฉด ๋„ˆ๋Š” ์ดˆ๋ณด
ยท
๐Ÿ Python
Python ์ฒ˜์Œ ์ ‘ํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์ด ํ•˜๋Š” ํ”ํ•œ ์‹ค์ˆ˜ 1) try ~ except~ ๊ตฌ๋ฌธ ๊ตฌ๋ฌธ ์‚ฌ์šฉํ•  ๋•Œ error๋ฌธ์„ ์ง์ ‘ ๊ทธ๊ฒƒ๋„ ์ด์ƒํ•˜๊ฒŒ ์ž‘์„ฑํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค. python์—์„œ ์‚ฌ์šฉํ•˜๋Š” error ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•˜๋ฉด ๋  ์ผ์„ ๋‚˜๋งŒ์ด ์•Œ์•„๋ณด๊ฒŒ ํ•ด๋†“๋Š”๊ฒƒ์ด ํฐ ์‹ค์ˆ˜๋กœ ์ด์–ด์ง„๋‹ค. [Worse] total: float = 0 while True: user_input: str = input("Add: ") try: total += float(user_input) except: print('์ˆซ์ž๋งŒ ์ž…๋ ฅํ•ด์ฃผ์‹œ์˜ค.') print(f"Current: {total}") [Better] total: float = 0 while True: user_input: str = input("Add: ") try: total += floa..
๋‹คํ–ˆ๋‹ค
'python' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก