yosuke-i commited on
Commit
2cb3de4
·
verified ·
1 Parent(s): 2270957

Update voice_create.py

Browse files
Files changed (1) hide show
  1. voice_create.py +7 -2
voice_create.py CHANGED
@@ -9,6 +9,7 @@ import re
9
  def remove_quotes(text):
10
  # ダブルクォートを空文字に置き換える
11
  return text.replace('"', '')
 
12
  def text_to_speech(input_file):
13
  # APIキーを直接コードに埋め込む(実際の運用では推奨されません)
14
  api_key = 'AIzaSyAEzK5_n6zKTimD9yoXS-C8O0xN_4LaVBQ' # ここを実際のAPIキーに置き換えてください
@@ -17,8 +18,13 @@ def text_to_speech(input_file):
17
 
18
  with zipfile.ZipFile(zip_path, 'w') as z:
19
  for idx, row in data.iterrows():
 
 
 
 
 
20
  # テキストをA:やB:で分割
21
- parts = re.split(r'(A:|B:)', row['script'])
22
  print(parts)
23
  ssml_parts = []
24
  print(parts)
@@ -81,6 +87,5 @@ def text_to_speech(input_file):
81
  os.remove(file_name)
82
  else:
83
  print("ファイル不備")
84
-
85
 
86
  return zip_path
 
9
  def remove_quotes(text):
10
  # ダブルクォートを空文字に置き換える
11
  return text.replace('"', '')
12
+
13
  def text_to_speech(input_file):
14
  # APIキーを直接コードに埋め込む(実際の運用では推奨されません)
15
  api_key = 'AIzaSyAEzK5_n6zKTimD9yoXS-C8O0xN_4LaVBQ' # ここを実際のAPIキーに置き換えてください
 
18
 
19
  with zipfile.ZipFile(zip_path, 'w') as z:
20
  for idx, row in data.iterrows():
21
+ # script列が文字列か確認し、文字列でない場合は空文字に置き換える
22
+ script = row.get('script', '')
23
+ if not isinstance(script, str):
24
+ script = str(script)
25
+
26
  # テキストをA:やB:で分割
27
+ parts = re.split(r'(A:|B:)', script)
28
  print(parts)
29
  ssml_parts = []
30
  print(parts)
 
87
  os.remove(file_name)
88
  else:
89
  print("ファイル不備")
 
90
 
91
  return zip_path