Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

TranscriptionSubtitles.web.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. /**
  5. * The type of the React {@code Component} props of
  6. * {@link TranscriptionSubtitles}.
  7. */
  8. type Props = {
  9. /**
  10. * Map of transcriptMessageID's with corresponding transcriptMessage.
  11. */
  12. _transcriptMessages: Map<string, Object>
  13. };
  14. /**
  15. * React {@code Component} which can display speech-to-text results from
  16. * Jigasi as subtitles.
  17. */
  18. class TranscriptionSubtitles extends Component<Props> {
  19. /**
  20. * Implements React's {@link Component#render()}.
  21. *
  22. * @inheritdoc
  23. * @returns {ReactElement}
  24. */
  25. render() {
  26. const paragraphs = [];
  27. for (const [ transcriptMessageID, transcriptMessage ]
  28. of this.props._transcriptMessages) {
  29. let text;
  30. if (transcriptMessage) {
  31. text = `${transcriptMessage.participantName}: `;
  32. if (transcriptMessage.final) {
  33. text += transcriptMessage.final;
  34. } else {
  35. const stable = transcriptMessage.stable || '';
  36. const unstable = transcriptMessage.unstable || '';
  37. text += stable + unstable;
  38. }
  39. paragraphs.push(
  40. <p key = { transcriptMessageID }>
  41. <span>{ text }</span>
  42. </p>
  43. );
  44. }
  45. }
  46. return (
  47. <div className = 'transcription-subtitles' >
  48. { paragraphs }
  49. </div>
  50. );
  51. }
  52. }
  53. /**
  54. * Maps the transcriptionSubtitles in the Redux state to the associated
  55. * props of {@code TranscriptionSubtitles}.
  56. *
  57. * @param {Object} state - The Redux state.
  58. * @private
  59. * @returns {{
  60. * _transcriptMessages: Map
  61. * }}
  62. */
  63. function _mapStateToProps(state) {
  64. return {
  65. _transcriptMessages: state['features/subtitles'].transcriptMessages
  66. };
  67. }
  68. export default connect(_mapStateToProps)(TranscriptionSubtitles);