# word, phrase, sentence scoring | sent.eval.jp
## Request Params
| Name           | Type             | Required | Default | Description                                                                                                                                                                                                                                     |
|----------------|------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `coreType`       | String           | true     |         | For Japanese word / sentence / phrase scoring, it's `sent.eval.jp`.                                                                                                                                                                                                               |
| `refText`        | String           | true     |         | The Japanese word, phrase or sentence to be spoken. The maximum limit is **400 characters**.                                                                                                                                |
| `getParam`       | Integer          | false    | `1`     | `0`: response **without** request params<br>`1`: response **with** request params                                                                                                                                                |
| `scale`          | Integer<br>Float | false    | `100`   | The scoring system. Range (0,100].<br>By default, it scores on a scale of 100. If you need five point system, use `5`.                                                                                                                          |
| `precision`      | Integer<br>Float | false    | `1`     | It defines how precise the scores should be. Range (0, 1].<br>For example, if you need scores ranging from 0, 0.5, 1.0,..., 4.5, 5.0, The `scale` should be `5`, and the `precision` should be `0.5`.|
| `dict_type`   | String           | false    |`hiragana`| Spefies the returned phoneme type. The optional values are `origin`(花: HA0 NA1) and `hiragana`(花:はな).|
| `slack` | Integer<br>Float | false    | `0` | It defines how strict the scoring should be.  Range `[-1,1]`. If you want the scoring results systematically a little bit higher, you can try `slack = 0.2`; significantly higher, try `slack = 0.5`; a little bit lower, try `slack = -0.2`; significantly lower, try `slack = -0.5`. |
| `realtime_feedback` | Integer | false| `0` | Real-time feedback during recording. Normally we use it to highlight the words just spoken. It's interactive and engaging. `0`: off; `1`: on.
| `readtype_diagnosis` | Integer | false| `0` | This parameter detects if a word is skipped or repeated. If a repetition is identified, the API provides scores for the repeated spoken word. Values: `0` (off), `1` (on).
| `customized_lexicon ` | Object | false    | - | Specifies a custom pronunciation for a single Japanese character or word. Examples:<br>`"customized_lexicon": {"上": ["うえ"]}`.<br>`"customized_lexicon":{"一番":["いちばん"]}`<br> `"customized_lexicon":{"上@1": ["うえ"], "上@2": ["かみ"]}`<br>@1, @2, etc. indicate the occurrence index in `refText` (e.g., first and second occurrence).<br> Only one pronunciation is allowed in the list.|


## Example Request
```json
{
    "param": {
        "app": {
            "userId": "xxx",
            "applicationId": "xxx",
            "timestamp": "xxx",
            "sig": "xxx"
        },
        "audio": {
            "audioType": "wav",
            "channel": 1,
            "sampleBytes": 2,
            "sampleRate": 16000
        },
        "request": {
            "coreType": "sent.eval.jp",
            "refText": "おはようございます",
            "readtype_diagnosis": 1
        }
    }
}
``` 
## Example Intermediate Response (`"realtime_feedback":1`)
```json
{
    "timestamp": "2020-10-30 16:13:19:224", 
    "eof": 0,                                    //0: intermediate result; 1: final result
    "recordId": "xxx",      //ID of the scoring
    "result": { 
        "kernel_version": "1.0.6", 
        "words": [
            {
                "charType": 0,                  //0: refText is current language, 1:not current language
                "scores": { 
                    "pronunciation": 61 
                },
                "word": "お" 
            }, {
                "charType": 0,
                "scores": {
                    "pronunciation": 48
                },
                "word": "元気"
            }
        ],
        "resource_version": "1.0.5" 
    }
}
```
## Intermediate result explanation
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `result`         | Object   | Score result object                                |
| `recordId`       | String   | Unique ID of the score                             |
| `timestamp`      | String   | Current timestamp                                |
| `eof`            | Integer  | `0`: is intermediate result <br> `1`: is final result |

### (immediate) result
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `kernel_version` | String       | Kernel version                                 |
| `resource_version`| String      | Resource version                               |
| `words`          | Array of objects | Word rating results                        |


### (immediate) result -> words
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `scores`         | Object   | Word score  <br>Note:If precision is set to floating point type, the value is displayed as floating point type (if the value is 0 after the decimal separator, it is displayed as integer type); if scale is set to (0,1), the value is displayed as floating point type; otherwise, it is displayed as integer type.          |
| `charType`       | Integer  | 0: refText is current 1:not current language |
| `word`           | String   | Word text       |

### (immediate) result -> words -> scores
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `pronunciation`  | Integer/Float  |Pronunciation score.|


## Example final Response
```json
{
  "refText": "おはようございます",
  "recordId": "xxx",
  "dtLastResponse": "2024-11-05 14:45:04:26",
  "applicationId": "xxx",
  "tokenId": "abcd",
  "params": {
    "app": {
      "applicationId": "xxx",
      "userId": "user_id",
      "sig": "1859dff81bcb85e68d1e5744e7245a516f4b9457",
      "timestamp": "1730789104"
    },
    "audio": {
      "audioType": "mp3",
      "sampleBytes": 2,
      "sampleRate": 16000,
      "channel": 1
    },
    "request": {
      "tokenId": "abcd",
      "readtype_diagnosis": 1,
      "refText": "おはようございます",
      "coreType": "sent.eval.jp"
    }
  },
  "result": {
    "warning": [
      {
        "message": "Audio noisy!",
        "code": 1004
      }
    ],
    "rhythm": 86,
    "overall": 90,
    "tone": 96,
    "speed": 252,
    "duration": "3.528",
    "resource_version": "1.2.9",
    "fluency": 79,
    "integrity": 100,
    "kernel_version": "1.3.9",
    "rear_tone": "rise",
    "numeric_duration": 3.528,
    "pronunciation": 91,
    "words": [
      {
        "charType": 0,
        "word": "おはよう",
        "scores": {
          "pronunciation": 96,
          "overall": 97,
          "prominence": 0
        },
        "readType": 0,
        "span": {
          "end": 132,
          "start": 70
        },
        "phonemes": [
          {
            "span": {
              "end": 82,
              "start": 70
            },
            "phoneme": "お",
            "pronunciation": 96,
            "tone": 0
          },
          {
            "span": {
              "end": 112,
              "start": 82
            },
            "phoneme": "は",
            "pronunciation": 96,
            "tone": 1
          },
          {
            "span": {
              "end": 132,
              "start": 112
            },
            "phoneme": "よ",
            "pronunciation": 96,
            "tone": 1
          }
        ],
        "tone_stats": {
          "ref_tone": "◎",
          "tone_score": 100
        },
        "word_parts": [
          {
            "part": "おはよう",
            "charType": 0,
            "beginIndex": 0,
            "endIndex": 3
          }
        ]
      },
      {
        "charType": 0,
        "word": "ござい",
        "scores": {
          "pronunciation": 89,
          "overall": 89,
          "prominence": 1
        },
        "readType": 0,
        "span": {
          "end": 178,
          "start": 132
        },
        "phonemes": [
          {
            "span": {
              "end": 149,
              "start": 132
            },
            "phoneme": "ご",
            "pronunciation": 89,
            "tone": 0
          },
          {
            "span": {
              "end": 168,
              "start": 149
            },
            "phoneme": "ざ",
            "pronunciation": 89,
            "tone": 1
          },
          {
            "span": {
              "end": 178,
              "start": 168
            },
            "phoneme": "い",
            "pronunciation": 89,
            "tone": 1
          }
        ],
        "tone_stats": {
          "ref_tone": "",
          "tone_score": 89
        },
        "word_parts": [
          {
            "part": "ござい",
            "charType": 0,
            "beginIndex": 4,
            "endIndex": 6
          }
        ]
      },
      {
        "charType": 0,
        "word": "ます",
        "scores": {
          "pronunciation": 88,
          "overall": 90,
          "prominence": 1
        },
        "readType": 0,
        "span": {
          "end": 284,
          "start": 225
        },
        "phonemes": [
          {
            "span": {
              "end": 249,
              "start": 225
            },
            "phoneme": "ま",
            "pronunciation": 99,
            "tone": 0
          },
          {
            "span": {
              "end": 284,
              "start": 249
            },
            "phoneme": "す",
            "pronunciation": 77,
            "tone": 1
          }
        ],
        "tone_stats": {
          "ref_tone": "◎",
          "tone_score": 100
        },
        "word_parts": [
          {
            "part": "ます",
            "charType": 0,
            "beginIndex": 7,
            "endIndex": 8
          }
        ]
      },
      {
        "charType": 0,
        "word": "ます",
        "readType": 4,
        "scores": {
          "overall": 89,
          "pronunciation": 89
        }
      }
    ]
  },
  "eof": 1
}
```

## Final result explanation
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `tokenId`        | String   | User request ID                                    |
| `result`         | Object   | Score result object                                |
| `applicationId`  | String   | AppKey                                             |
| `recordId`       | String   | Unique ID of the score                             |
| `params`         | Object   | Request parameters                                 |
| `refText`        | String   | Reference information                              |
| `eof`            | Integer  | `0`: is intermediate result;<br>`1`: is final result |
| `dtLastResponse` | String  | The datetime of the reponse.|



### Result
| Property                  | Type           | Description                                                                                      |
|---------------------------|----------------|--------------------------------------------------------------------------------------------------|
| `overall`                 | Integer/Float  | Overall score.<br> It covers fluency, completeness (integrity), pronunciation, tone and rhythm scores.|
| `pronunciation`           | Integer/Float  | Pronunciation score. <br> It reflects precision of sound production and does not cover tone aspects. |
| `fluency`                 | Integer/Float  | The fluency score. <br>The fluency score indicates how smoothly the speaker delivers their speech. Fluency score is calculated by dividing the length of pauses and silence during the speech by the length of the speech. |
| `tone`                    | Integer/Float    | Tone score. <br> It reflects how accurate the tone is produced.|
| `rhythm`                 | Integer/Float  | The rhythm score. <br> Rhythm score assesses the user's ability to use suprasegmental features, such as tone and stress, to convey meaning and create natural-sounding speech. Rhythm score, like pronunciation, is calculated using a model trained on thousands of hours of scripted audio from native speakers. However, it's less interpretable.|
| `integrity`           | Integer/Float  | The completeness score. <br>It's the proportion of words that are spoken based on the reference text.|
| `speed`                 | Integer | Speech rate in characters per minute.|
| `rear_tone`           | Integer/Float  | The intonation at the end of the sentence. <br>Supported values: `rise` and `fall`.|
| `words`                   | Array of objects  | Word information|
| `duration`                | String  | Audio duration|
| `kernel_version`          | String         | Kernel version.|
| `resource_version`        | String         | Resource version.    |
| `warning`                | Array of objects        | Error codes and messages if returned.|


### result -> warning
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `code`           | Integer  |Please see the complete warnings here: [Warning list](../../Warnings.md)                    |
| `message`        | String   |Please see the complete warnings here: [Warning list](../../Warnings.md)  


### result -> words[i]
>Note: When the `readtype_diagnosis` parameter is enabled, the words array data is displayed as the actual pronunciation. 

| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `scores`         | Object   | Word score details |
| `charType`       | Integer  | `0`: This character is current language.<br>`1`: This character is not current language  |
| `word`           | String   | The word.|
| `span`           | Object   | The start and end timestamps of the word.|
| `phonemes`       | Array of objects    | Phoneme scores.|
| `tone_stats`       | Array of objects  | The details of tone scores. |
| `readType `    | integer | `0`: normally spoken word. <br> `3`: skipped word. <br>`4`: repeated word|
| `word_parts`     | Array of objects    | The word split into character-level parts. |

### result -> words[i] -> word_parts
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `part`  | String | The text of this part of the word. |
| `charType`  | Integer | 0: refText is current language, 1: not current language. |
| `beginIndex`  | Integer | The start character index of the part within `refText` (0-based). |
| `endIndex`  | Integer | The end character index of the part within `refText` (0-based). |

### result -> words[i] -> scores
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `overall`        | Integer/Float | The score only covers pronunciation and does not take tone into account. Same as `pronunciation`.|
| `pronunciation`  | Integer/Float  |Same as `overall`.|
| `prominence `    | Integer    |It detects if this word is emphasized.<br>`1`: emphasized <br> `0`: not emphasized|

### result -> words[i] -> span
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
|`start` |Integer|The start time of the word on the audio, in 10 milliseconds|
|`end`   |Integer|The end time of the word on the audio, in 10 milliseconds|


### result -> words[i] -> tone_stats
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `ref_tone`  | string |The phonetic types. Supported values: `null`, `◎`, `①`, `②`, `③`, `④`, `⑤`, `⑥`. It may also return phonetic type combination.|
| `tone_score`           | Integer/Float  | Tone score (same as `result -> tone`)             |

### result -> words[i] -> phonemes[i]
| Property         | Type     | Description                                        |
|------------------|----------|----------------------------------------------------|
| `pronunciation`  | Integer/Float |The pronunciation score of this phoneme.|
| `tone`        | Integer| The reference pitch accent. <br>`-1`: No tone <br> `0`: Low tone <br> `1`: high tone|
| `phoneme`  |String| The phonetic symbol of this phoneme.|
| `span`  | Object | The time of the phoneme on the track |

### result -> words[i] -> phonemes[i] -> span
| Property         | Type     | Description                                           |
|------------------|----------|-------------------------------------------------------|
| `start`          | Integer  | Start time of the phoneme on the audio (in 10 milliseconds)         |
| `end`            | Integer  | End time of the phoneme on the audio (in 10 milliseconds)           |
