From 901bb4c3d113001fb7abf821d98e1750b5eb7896 Mon Sep 17 00:00:00 2001
From: zuoban <1061669148@qq.com>
Date: Tue, 12 Aug 2025 14:09:04 +0800
Subject: [PATCH] feat: add logging for voice list retrieval from cache and fix
loading option text
---
internal/tts/microsoft/client.go | 3 +++
web/templates/index.html | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/internal/tts/microsoft/client.go b/internal/tts/microsoft/client.go
index c73a1ec..b481605 100644
--- a/internal/tts/microsoft/client.go
+++ b/internal/tts/microsoft/client.go
@@ -117,6 +117,8 @@ func (c *Client) ListVoices(ctx context.Context, locale string) ([]models.Voice,
// 检查缓存是否有效
c.voicesCacheMu.RLock()
if !c.voicesCacheExpiry.IsZero() && time.Now().Before(c.voicesCacheExpiry) && len(c.voicesCache) > 0 {
+ // 从缓存中获取
+ log.Println("ListVoices 从缓存中获取语音列表: ", len(c.voicesCache), "个", "剩余时间:", c.voicesCacheExpiry.Sub(time.Now()))
voices := c.voicesCache
c.voicesCacheMu.RUnlock()
@@ -135,6 +137,7 @@ func (c *Client) ListVoices(ctx context.Context, locale string) ([]models.Voice,
c.voicesCacheMu.RUnlock()
// 缓存无效,需要从API获取
+ log.Println("ListVoices, 缓存未命中,从API获取语音列表")
endpoint, err := c.getEndpoint(ctx)
if err != nil {
return nil, err
diff --git a/web/templates/index.html b/web/templates/index.html
index 94fade8..f662309 100644
--- a/web/templates/index.html
+++ b/web/templates/index.html
@@ -947,7 +947,7 @@