1 コミット

作成者 SHA1 メッセージ 日付
みてるぞ 5e82637845 特定の音声を素材に変換する用のブランチ 2024-02-15 01:47:57 +09:00
28個のファイルの変更256行の追加1200行の削除
+1 -4
ファイルの表示
@@ -1,8 +1,5 @@
/connection.py /connection.py
__pycache__ /__pycache__
/nizika_talking.wav /nizika_talking.wav
/youtube.py /youtube.py
/log.txt /log.txt
/outputs/**
!/outputs/**/
!/outputs/**/.gitkeep
-3
ファイルの表示
@@ -1,3 +0,0 @@
[submodule "nizika_ai"]
path = nizika_ai
url = https://git.miteruzo.com/miteruzo/nizika_ai
+3 -4
ファイルの表示
@@ -1,12 +1,11 @@
from ctypes import *
import subprocess import subprocess
from ctypes import ARRAY # type: ignore
from ctypes import POINTER, byref, c_int, c_ubyte, cast, cdll
class Aques: class Aques:
@classmethod @classmethod
def main (cls, text: str, goatoh_mode: bool = False) -> bytearray | None: def main (cls, text: str) -> bytearray | None:
return cls.__synthe_utf8 (text, 100, './phont/ar_m5.phont' if goatoh_mode else './phont/ar_mf2.phont') return cls.__synthe_utf8 (text, 100, "./phont/ar_mf2.phont")
@staticmethod @staticmethod
def __synthe_utf8 (text, speed, phont_file = None) -> bytearray | None: def __synthe_utf8 (text, speed, phont_file = None) -> bytearray | None:
バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 57 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 99 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 53 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 40 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.
バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 166 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 641 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.
バイナリ
ファイルの表示
バイナリファイルは表示されません.
バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 554 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更前

幅:  |  高さ:  |  サイズ: 463 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.
+5 -18
ファイルの表示
@@ -3,24 +3,15 @@ import unicodedata
class CommonModule: class CommonModule:
@staticmethod @staticmethod
def is_wide ( def is_wide (c: str) -> bool:
c: str) \
-> bool:
return unicodedata.east_asian_width (c) in ['F', 'W', 'A'] return unicodedata.east_asian_width (c) in ['F', 'W', 'A']
@classmethod @classmethod
def len_by_full ( def len_by_full (cls, string: str) -> float:
cls,
string: str) \
-> float:
return sum (1 if cls.is_wide (c) else .5 for c in string) return sum (1 if cls.is_wide (c) else .5 for c in string)
@classmethod @classmethod
def index_by_f2c ( def index_by_f2c (cls, string: str, index: float) -> int:
cls,
string: str,
index: float) \
-> int:
i: int = 0 i: int = 0
work: str = '' work: str = ''
for c in string: for c in string:
@@ -33,12 +24,8 @@ class CommonModule:
return i return i
@classmethod @classmethod
def mid_by_full ( def mid_by_full (cls, string: str, start: float, length: float) -> str:
cls,
string: str,
start: float,
length: float) \
-> str:
trimmed_left: str = string[cls.index_by_f2c (string, start):] trimmed_left: str = string[cls.index_by_f2c (string, start):]
return trimmed_left[:cls.index_by_f2c (trimmed_left, length)] return trimmed_left[:cls.index_by_f2c (trimmed_left, length)]
+7
ファイルの表示
@@ -0,0 +1,7 @@
# 各変数に適切な値を設定し,ファイル名を connection.py として保存すること
OPENAI_ORGANISATION: str = 'org-XXXXXXXXXXXXXXXXXXXXXXXX' \
# Organisation ID
OPENAI_API_KEY: str = 'sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
# API Key
+82
ファイルの表示
@@ -0,0 +1,82 @@
Traceback (most recent call last):
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
yield
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_backends/sync.py", line 126, in read
return self._sock.recv(max_bytes)
File "/usr/lib/python3.10/ssl.py", line 1288, in recv
return self.read(buflen)
File "/usr/lib/python3.10/ssl.py", line 1161, in read
return self._sslobj.read(len)
TimeoutError: The read operation timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions
yield
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 228, in handle_request
resp = self._pool.handle_request(req)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 268, in handle_request
raise exc
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 251, in handle_request
response = connection.handle_request(request)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/connection.py", line 103, in handle_request
return self._connection.handle_request(request)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 185, in handle_request
raise exc
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 148, in handle_request
status, headers = self._receive_response(
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 292, in _receive_response
event = self._receive_stream_event(request, stream_id)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 333, in _receive_stream_event
self._receive_events(request, stream_id)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 361, in _receive_events
events = self._read_incoming_data(request)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 452, in _read_incoming_data
raise exc
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_sync/http2.py", line 438, in _read_incoming_data
data = self._network_stream.read(self.READ_NUM_BYTES, timeout)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_backends/sync.py", line 124, in read
with map_exceptions(exc_map):
File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadTimeout: The read operation timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/miteruzo/Downloads/nizika_broadcast/main.py", line 117, in <module>
Main.main ()
File "/home/miteruzo/Downloads/nizika_broadcast/main.py", line 106, in main
live_chat = pytchat.create (video_id = YOUTUBE_ID)
File "/home/miteruzo/.local/lib/python3.10/site-packages/pytchat/core/__init__.py", line 7, in create
return PytchatCore(_vid, **kwargs)
File "/home/miteruzo/.local/lib/python3.10/site-packages/pytchat/core/pytchat.py", line 96, in __init__
self._setup()
File "/home/miteruzo/.local/lib/python3.10/site-packages/pytchat/core/pytchat.py", line 106, in _setup
channel_id=util.get_channelid(self._client, self._video_id),
File "/home/miteruzo/.local/lib/python3.10/site-packages/pytchat/util/__init__.py", line 103, in get_channelid
resp = client.get("https://www.youtube.com/embed/{}".format(quote(video_id)), headers=config.headers)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 1041, in get
return self.request(
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 814, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 901, in send
response = self._send_handling_auth(
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 929, in _send_handling_auth
response = self._send_handling_redirects(
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 966, in _send_handling_redirects
response = self._send_single_request(request)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_client.py", line 1002, in _send_single_request
response = transport.handle_request(request)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 227, in handle_request
with map_httpcore_exceptions():
File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/home/miteruzo/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout: The read operation timed out
+100 -1045
ファイルの表示
ファイル差分が大きすぎるため省略します 差分を読込み
-2
ファイルの表示
@@ -1,2 +0,0 @@
[mypy]
disable_error_code = import-untyped
サブモジュール nizika_ai1f75763038 から削除されました
ファイルの表示
-32
ファイルの表示
@@ -1,32 +0,0 @@
import pygame
from pygame.locals import *
import sys
class Othello:
SCREEN_SIZE: tuple = (640, 480)
BOARD_COLOUR: tuple = (0, 128, 0)
@classmethod
def main (cls) -> None:
pygame.init ()
screen: pygame.Surface = pygame.display.set_mode (cls.SCREEN_SIZE)
while True:
screen.fill ((0, 0, 0))
# pygame.draw.rect (screen, BOARD_COLOUR, )
pygame.display.update ()
pygame.time.wait (33)
for event in pygame.event.get ():
if event.type == QUIT:
pygame.quit ()
sys.exit ()
if __name__ == '__main__':
Othello.main ()
ファイルの表示
+60
ファイルの表示
@@ -0,0 +1,60 @@
import sys
import openai
from openai.types import *
from datetime import datetime
from connection import *
class Talk:
DUMMY_RESPONSE: str = 'あいうえおかきくけこさしすせそたちつてとなにぬねの'
max_tokens_count: int = 100
responses_count: int = 1
temperature: float = .7
top_p: int = 1
@classmethod
def main (cls, message: str, name: str | None = None, histories: list = []) -> str:
openai.organization = OPENAI_ORGANISATION
openai.api_key = OPENAI_API_KEY
answer: chat.chat_completion_message.ChatCompletionMessage | None \
= cls.__get_message (message, name, histories)
return cls.DUMMY_RESPONSE if answer is None else answer.content
@classmethod
def __get_message (cls, message: str, name: str | None, histories: list) \
-> chat.chat_completion_message.ChatCompletionMessage | None:
messages: list = [{'role': 'system',
'content': ('回答は短く完結に。'
+ 'assistantの名前は伊地知ニジカ。'
+ '誕生日は12/3。'
+ '現在地は下北沢虹鹿園。'
+ '趣味はニコニコでエゴサすること。'
+ '友達は「ゴートうひとり」と「ラマ田リョウ」。'
+ 'ゴートうのことは「ボッチチャーン」、ラマ田のことは「リョウ」と呼ぶ。'
+ 'ゴートうは男の子だが、性自認はメスである。'
+ '喜多ちゃんが大好き。'
+ 'ニジカは喜多ちゃんを見ると追いかけたくなっちゃう。'
+ '逃げたギターは喜多ちゃんのこと。'
+ '喜多ちゃんの本名は喜多郁代。'
+ 'すべての語尾に「ぬ゛ん」か「だぬ゛ん」をつけて質問に短く答えろ。'
+ '定期的に「ぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛」と発しろ。'
+ (f'userの名前は「{name}」。' if name is not None else '')
+ f'現在日時{datetime.now ().strftime ("%Y/%m/%d %H:%M:%S")}')}]
messages += histories + [{'role': 'user', 'content': message}]
try:
return openai.chat.completions.create (
model = 'gpt-3.5-turbo',
messages = messages).choices[0].message
except openai.AuthenticationError:
return None
if __name__ == '__main__':
print (Talk.main (sys.argv[1] if len (sys.argv) > 1 else ''))
ファイルの表示

変更前

幅:  |  高さ:  |  サイズ: 17 KiB

変更後

幅:  |  高さ:  |  サイズ: 17 KiB

-96
ファイルの表示
@@ -1,96 +0,0 @@
from typing import Any
DEFAULT_W, DEFAULT_H = 1280, 720
FONT_NAME = 'Noto Sans CJK JP'
BASE_FONT = 42
SCROLL_DURATION = 4.
STATIC_DURATION = 3.
MARGIN_X = 20
LANE_PADDING = 6
def ass_time (
t: float,
) -> str:
if t < 0:
t = 0
cs = int (round (t * 100))
s, cs = divmod (cs, 100)
m, s = divmod (s, 60)
h, m = divmod (m, 60)
return f"{h}:{m:02d}:{s:02d}.{cs:02d}"
def escape_ass (
text: str,
) -> str:
text = text.replace ('\n', ' ').replace ('\r', ' ')
text = text.replace ('{', r'\{').replace ('}', r'\}')
text = text.replace ('\\', r'\\')
return text.strip ()
def approx_text_width_px (
text: str,
font_size: float,
) -> float:
return max (40., .62 * font_size * len (text))
def build_ass (
comments: list[dict[str, Any]],
w: int,
h: int,
) -> str:
header = f"""[Script Info]
ScriptType: v4.00+
PlayResX: {w}
PlayResY: {h}
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Danmaku,{FONT_NAME},{BASE_FONT},&H00FFFFFF,&H00000000,&H00000000,&H64000000,0,0,0,0,100,100,0,0,1,2,1,7,{MARGIN_X},{MARGIN_X},10,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
"""
events: list[str] = []
lane_h = int (BASE_FONT + LANE_PADDING)
lane_count = max (6, (h - 80) // lane_h)
lane_next_free = [0.] * lane_count
top_rows = max (1, (h // 5) // lane_h)
bottom_rows = top_rows
top_next_free = [0.] * top_rows
bottom_next_free = [0.] * bottom_rows
def pick_lane (
next_free: list[float],
start: float,
) -> int:
for i, nf in enumerate (next_free):
if nf <= start:
return i
return min (range (len (next_free)), key = lambda i: next_free[i])
for c in comments:
text = escape_ass (c['content'])
if not text:
continue
start = c['vpos_ms']
end = c['vpos_ms'] + SCROLL_DURATION
lane = pick_lane (lane_next_free, start)
y = 40 + lane * lane_h
tw = approx_text_width_px (text, 1.)
x1 = w + MARGIN_X
x2 = -tw - MARGIN_X
lane_next_free[lane] = start + (SCROLL_DURATION * .65)
override = rf"{{\fs1\c&H00FFFFFF\move({int(x1)},{int(y)},{int(x2)},{int(y)})}}"
events.append (
f"Dialogue: 0,{ass_time(start)},{ass_time(end)},Danmaku,,0,0,0,,{override}{text}")
return header + '\n'.join (events) + '\n'
+3
ファイルの表示
@@ -0,0 +1,3 @@
# 各変数に適切な値を設定し,ファイル名を youtube.py として保存すること
YOUTUBE_ID: str = 'XXXXXXXXXXX' # YouTube の配信 ID