Last active
December 30, 2025 04:39
-
-
Save sharl/fac8f6bffa3a30fcd5b9bc41ea18e527 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| # | |
| # vvox.py: https://github.com/sharl/amedas/blob/e2a02ba028b1fbc71371b6894d18109513f148d2/vvox.py | |
| # pip install -U bs4 requests pyaudio | |
| # | |
| import sys | |
| import time | |
| from bs4 import BeautifulSoup | |
| from vvox import vvox | |
| import requests | |
| DEBUG = len(sys.argv) > 1 | |
| base_url = 'https://hiroba.dqx.jp/sc/event/newyear2026' | |
| tasks = { | |
| 400000: '紫の上錬金石10個', | |
| 800000: 'ゴルスラメダル3枚', | |
| 1200000: 'メタル迷宮招待券3枚', | |
| 1600000: 'ふくびき券99枚', | |
| 2026000: '馬蹄のイヤリング', | |
| } | |
| pre_text = str() | |
| count = 9 | |
| lines = [] | |
| while True: | |
| with requests.get(base_url) as r: | |
| soup = BeautifulSoup(r.content, 'html.parser') | |
| status = soup.find(class_='event-status-text') | |
| defeated = int(status.dd.text.split('体')[0].replace(',', '')) | |
| if DEBUG: | |
| count += 100000 | |
| defeated += count | |
| text = str() | |
| for num in tasks: | |
| if defeated >= num and num not in lines: | |
| text = f'{tasks[num]} 達成' | |
| lines.append(num) | |
| elif defeated < num and num not in lines: | |
| text = f'{tasks[num]}まであと{num - defeated}体' | |
| break | |
| for num in lines: | |
| if num in tasks: | |
| del tasks[num] | |
| complete = False | |
| if not tasks: | |
| text = 'すべて達成' | |
| complete = True | |
| if pre_text != text: | |
| msg = f'{text}なのだ' | |
| print(msg) | |
| vvox(msg, speed=1.2) | |
| pre_text = text | |
| if complete: | |
| break | |
| time.sleep(60) |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| import io | |
| import wave | |
| import pyaudio | |
| import requests | |
| def vvox(text, host='127.0.0.1', port=50021, speaker=3, speed=1.0, volume=1.0): | |
| params = { | |
| 'text': text, | |
| 'speaker': speaker, | |
| } | |
| query = requests.post( | |
| f'http://{host}:{port}/audio_query', | |
| params=params, | |
| timeout=10, | |
| ) | |
| qp = query.json() | |
| # modify query | |
| qp['speedScale'] = speed | |
| qp['volumeScale'] = volume | |
| synthesis = requests.post( | |
| f'http://{host}:{port}/synthesis', | |
| params=params, | |
| json=qp, | |
| timeout=10, | |
| ) | |
| with wave.open(io.BytesIO(synthesis.content), 'rb') as wf: | |
| data = wf.readframes(wf.getnframes()) | |
| pya = pyaudio.PyAudio() | |
| stream = pya.open( | |
| format=pya.get_format_from_width(wf.getsampwidth()), | |
| channels=wf.getnchannels(), | |
| rate=wf.getframerate(), | |
| output=True, | |
| ) | |
| stream.write(data) | |
| stream.stop_stream() | |
| stream.close() | |
| pya.terminate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment