You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用g2p_en包时遇dataclass_transform()参数错误求助

解决g2p_en运行报错dataclass_transform() got an unexpected keyword argument 'field_specifiers'的方法

这个错误是由于依赖库版本不兼容导致的:typing_extensions库的新版本修改了dataclass_transform函数的参数,而g2p_en依赖的其他库仍在使用旧参数调用方式。

修复步骤:

  1. 卸载当前的typing_extensions:
!pip uninstall -y typing_extensions
  1. 安装兼容的旧版本(4.10.0版本与旧依赖参数匹配):
!pip install typing_extensions==4.10.0
  1. 重新运行示例代码:
from g2p_en import G2p

texts = ["I have $250 in my pocket.", # number -> spell-out
         "popular pets, e.g. cats and dogs", # e.g. -> for example
         "I refuse to collect the refuse around here.", # homograph
         "I'm an activationist."] # newly coined word
g2p = G2p()
for text in texts:
    out = g2p(text)
    print(out)

补充方案(若上述步骤无效):

同时锁定transformers的版本到4.x系列(如4.30.2),避免新版本引发的参数冲突:

!pip install transformers==4.30.2

内容的提问来源于stack exchange,提问作者Turing101

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 13:40:35