Spaces:
Runtime error
Runtime error
| async function getTranscription() { | |
| try { | |
| const response = await fetch("/transcription"); | |
| if (!response.ok) { | |
| throw new Error("HTTP error! status: ${response.status}"); | |
| } | |
| const data = await response.json; | |
| const results = data.response; | |
| } catch (error) { | |
| console.error("Failed to fetch transcription", error); | |
| } | |
| } | |
| async function getAnalysis() { | |
| const loader = document.getElementById("loader"); | |
| loader.style.display = "block"; | |
| try { | |
| await getTranscription(); | |
| const response = await fetch("/analyze"); | |
| if (!response.ok) { | |
| throw new Error(`HTTP error! status: ${response.status}`); | |
| } | |
| const data = await response.json(); | |
| const results = data.results; | |
| const analysis = results.deepseek_analysis; | |
| // 変数に格納 | |
| const conversationLevel = analysis.conversationLevel; | |
| const harassmentPresent = analysis.harassmentPresent; | |
| const harassmentType = analysis.harassmentType; | |
| const repetition = analysis.repetition; | |
| const pleasantConversation = analysis.pleasantConversation; | |
| const blameOrHarassment = analysis.blameOrHarassment; | |
| if (harassmentPresent) { | |
| harassmentPresent = "あり"; | |
| } else { | |
| harassmentPresent = "なし"; | |
| } | |
| if (harassmentType == null) { | |
| harassmentType = "該当なし"; | |
| } | |
| loader.style.display = "none"; | |
| // DOMに表示 | |
| document.getElementById( | |
| "level" | |
| ).innerText = `会話レベル: ${conversationLevel}`; | |
| document.getElementById( | |
| "Harassment_bool" | |
| ).innerText = `ハラスメントの有無: ${harassmentPresent}`; | |
| document.getElementById( | |
| "Harassment_type" | |
| ).innerText = `ハラスメントの種類: ${harassmentType}`; | |
| document.getElementById( | |
| "Harassment_loop" | |
| ).innerText = `繰り返しの程度: ${repetition}`; | |
| document.getElementById( | |
| "Harassment_comfort" | |
| ).innerText = `会話の心地よさ: ${pleasantConversation}`; | |
| document.getElementById( | |
| "Harassment_volume" | |
| ).innerText = `非難またはハラスメントの程度: ${blameOrHarassment}`; | |
| } catch (error) { | |
| loader.style.display = "none"; | |
| console.error("Failed to fetch analysis data:", error); | |
| } | |
| } | |
| window.onload = getAnalysis(); | |