-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #259 from tegnike/develop
本番リリース
- Loading branch information
Showing
15 changed files
with
262 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Talk } from './messages' | ||
|
||
export async function synthesizeVoiceNijivoiceApi( | ||
talk: Talk, | ||
apiKey: string, | ||
voiceActorId: string, | ||
speed: number | ||
) { | ||
try { | ||
const res = await fetch('/api/tts-nijivoice', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
script: talk.message, | ||
speed, | ||
voiceActorId, | ||
apiKey, | ||
}), | ||
}) | ||
|
||
if (!res.ok) { | ||
throw new Error( | ||
`Nijivoice APIからの応答が異常です。ステータスコード: ${res.status}` | ||
) | ||
} | ||
|
||
return await res.arrayBuffer() | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
throw new Error(`Nijivoiceでエラーが発生しました: ${error.message}`) | ||
} else { | ||
throw new Error('Nijivoiceで不明なエラーが発生しました') | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { NextApiRequest, NextApiResponse } from 'next' | ||
|
||
export default async function handler( | ||
req: NextApiRequest, | ||
res: NextApiResponse | ||
) { | ||
const { apiKey } = req.query | ||
|
||
const nijivoiceApiKey = apiKey || process.env.NIJIVOICE_API_KEY | ||
if (!nijivoiceApiKey) { | ||
return res.status(400).json({ error: 'API key is required' }) | ||
} | ||
|
||
try { | ||
const response = await fetch( | ||
'https://api.nijivoice.com/api/platform/v1/voice-actors', | ||
{ | ||
headers: { | ||
'x-api-key': nijivoiceApiKey as string, | ||
}, | ||
} | ||
) | ||
const data = await response.json() | ||
return res.status(200).json(data) | ||
} catch (error) { | ||
console.error('Failed to fetch voice actors:', error) | ||
return res.status(500).json({ error: 'Failed to fetch voice actors' }) | ||
} | ||
} |
Oops, something went wrong.