Jesus is not attributed to be speaking in either John 12:38 or 40 according to a "red letter" edition.
However, regarding verse 38 Ellicott's Commentary for English Readers states:
Lord, who hath believed our report? The quotation is from the Greek version of Isaiah 53:1. That prophecy was by all understood of the Messiah. The prophet’s lamentation of the neglect of the prophetic message by the people is here placed by the Evangelist, in his interpretation of it, in the lips of the Messiah Himself, as He, in the fuller meaning, addresses the Father with the words, "Who hath believed our report?"...
Also, in regards to verse 38, Meyer's NT Commentary states:
The passage is Isaiah 53:1, closely following the LXX. The lament of the prophet over the unbelief of his time towards his preaching (and that of his fellows, ἡμῶν), and towards the mighty working of God announced by him, has, according to the Messianic character of the whole grand oracle, its reference and fulfilment in the unbelief of the Jews towards Jesus; so that in the sense of this fulfilment, the speaking subject (addressing God, κύριε, comp. Matthew 27:46), which Isaiah introduces, is Jesus, not the evangelist and those of like mind with him (Luthardt).
Regarding verse 40, the commentary indicates that John's quotation is Jesus first person: Bengel's Gnomen
John 12:40. Τετύφλωκεν, hath blinded) God, by a just judgment on them. There follows, with a change of person, I the Messiah should heal them.—πεπώρωκεν)
Also, regarding verse 40, since Jesus connects the fulfillment of this prophecy in Matthew 13:14, could it be inferred that John (as others do) are reciting what Jesus has already acknowledged and the attribution should be to Jesus? Ellicott's Commentary for English Readers
He hath blinded their eyes, and hardened their heart. . . .—These words are quoted three times in the New Testament. Our Lord, as we have seen, quotes them as explaining His own teaching (Matthew 13:14); St. John quotes them here to explain the rejection of that teaching;
[emphasis added]